0

I'm new to PHP and WooCommerce and haven't been able to find an answer to my simple WooCommerce customization. I want to override the shopping cart and checkout totals in WooCommerce to my own value. I have been able to update the subtotal, but not the shopping cart total. To update the subtotal, I can use the code below.

function add_custom_price( $cart_object ) {

$cart_object->subtotal *= 12;

}

add_action( 'woocommerce_calculate_totals', 'add_custom_price', 10, 1);

But how do I override the standard cart / checkout total instead of just the subtotal?

Another alternative may be to show an information only donation line that doesn't impact the cart. I think either solution would work for my issue.

Thanks

SE-ME
  • 1
  • 1
  • Possible duplicate of [Woocommerce get total on checkout page](https://stackoverflow.com/questions/39529582/woocommerce-get-total-on-checkout-page) – Asif Raza Jun 04 '17 at 22:15
  • 2
    Override the total? Why would you need / want to do that? – random_user_name Jun 04 '17 at 22:22
  • We want to take donations on our page, but for the donation amount to come out of the total and for the user to still pay the same amount. I can get the cart to display a "donation line" with a set amount. But it impacts the cart total. I want to show the donation amount, but not impact the total. If I can manually update the total, I can display the donation and set the cart total to the correct unaffected amount. Hopefully that makes sense... – SE-ME Jun 04 '17 at 23:55
  • I guess an alternative way of doing this would be to show an informational "donation line" that doesn't impact the shopping cart total, but I'm not sure how to do that either. – SE-ME Jun 05 '17 at 00:14
  • Hi @cale_b, I wanted to see if you had any insight into how I might do this? Thx. – SE-ME Jun 05 '17 at 22:15

0 Answers0