单击按钮时如何更新结帐迷你购物车总价

时间:2019-10-04 18:20:05

标签: php ajax wordpress woocommerce checkout

我想在单击按钮时更新购物车的总金额,但总金额未更新,这是我的PHP代码

add_action( 'wp_ajax_update_order_review', "update_order_review" );
add_action( 'wp_ajax_nopriv_update_order_review', "update_order_review" );

function update_order_review() {

    WC()->cart->set_total( 'total', 123 );

    wp_die();
}

这是我的JS代码

 $( '.custom-mycred-price-value-redeem.btn' ).click( function(e) {
    e.preventDefault();
    var data = {
    action: 'update_order_review',
    security: wc_checkout_params.update_order_review_nonce,
    post_data: $( 'form.checkout' ).serialize(),
        points_value: $( 'input.custom-mycred-points-range-slider' ).val(),
    };

  jQuery.post( mycred_points_redeem_ajax, data, function( response ){
     $( 'body' ).trigger( 'update_checkout' );
  });
}); 

有人可以帮我吗?

0 个答案:

没有答案
相关问题