skip to Main Content

I changed the total price by using this WC()->cart->set_total(123456), but when i pay using a credit card, the amount paid is the normal amount, it should be 12345 but looks like WC()->cart->set_total(12345) only works to change the total price inside the shopping cart.

Any thoughts? Thanks

2

Answers


  1. This is fairly vague and not sure why you are trying to set the carts total vs an items total. But something like this I believe is what you are looking for.

    Change Cart total using Hooks in Woocommerce 3.2+

    Login or Signup to reply.
  2. Try this:

    add_action( 'woocommerce_review_order_before_order_total', 'mod_cart_total' );
    function mod_cart_total() {
    
        if ( is_admin() && ! defined( 'DOING_AJAX' ) )
                return;
    
        WC()->cart->total = 12345;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search