0

I'm using Pricing deals pro plugin and i have a custom theme which displays a custom cart on shop page. I've created ajax functions for cart items update and cart price update:

For the item update i'm using this functionality:

add_action( 'wp_ajax_nopriv_upate-cartitem-filter', 'prefix_update_cart_item' );
add_action( 'wp_ajax_upate-cartitem-filter', 'prefix_update_cart_item' );

function prefix_update_cart_item (){

    $product_key = $_POST[ 'itemkey' ];
    $item_quantity = $_POST[ 'itemamount' ];

    global $woocommerce;
    wc()->cart->set_quantity($product_key, $item_quantity, true);

    die();
}

To get cart totals i'm using this one:

add_action( 'wp_ajax_nopriv_upate-carttotal-filter', 'prefix_update_cart_total' );
add_action( 'wp_ajax_upate-carttotal-filter', 'prefix_update_cart_total' );

function prefix_update_cart_total(){

    global $woocommerce;    

    $total_price = WC()->cart->get_cart_total();

    echo $total_price;
}

When i'm updating the product using standard AJAX i'm getting the totals without the pricing deals plugin calculations, only after page refresh i'm getting the price after the deal. What am i missing?

0

If you want to update your cart after a property change (such as price or item quantity), you might want to take a look at this:

https://gist.github.com/mikaelz/f41e29c6a99a595602e4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.