admin管理员组文章数量:1410674
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?
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?
Share Improve this question edited Sep 16, 2018 at 14:18 Gil asked Sep 16, 2018 at 14:12 GilGil 113 bronze badges1 Answer
Reset to default 1If 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/mikaelz/f41e29c6a99a595602e4
本文标签: Woocommerce and Pricing deals plugin total price update with AJAX
版权声明:本文标题:Woocommerce and Pricing deals plugin total price update with AJAX 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744995330a2636636.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论