Timeline for How do I hook a custom discount to change a WC_Order price total on WooCommerce?
Current License: CC BY-SA 4.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 29, 2018 at 12:05 | comment | added | John Doe |
Thanks! I tweaked my code so that it doesn't use coupons. Instead, the data is saved in WC()->session and shown through hooks onto the basket and checkout totals section. By the way, I used to do MMA too! Really enjoyed it. But I was often on the side that got their ass kicked.
|
|
Sep 28, 2018 at 13:10 | comment | added | Matt Royal |
There may be better filters to use but I don't really think it will matter much, so long as you are manipulating the cart data on the cart page to apply your coupon. With regards to being future proof, I don't see the woocommerce_cart_subtotal being changed or taken out, its integral into the cart/checkout process and the same applies to coupons - all in all it should be pretty reliable going forward. What I would suggest looking into is a scenario where actual coupons need to be used as well, in conjunction with your store credits. The code will need to be tweaked to handle that...
|
|
Sep 28, 2018 at 10:19 | vote | accept | John Doe | ||
Sep 28, 2018 at 10:17 | comment | added | John Doe |
Thanks for the response! I added a field above the Apply Coupons field in the cart page for users to key in the amount of store credits they want to use, then stored the credits in the session variable. Then I used your hook to apply that as a coupon. I'm concerned that the woocommerce_cart_subtotal may not be future-proof, since it is quite an unusual hack. What do you think are the odds of a future WooCommerce plugin breaking this?
|
|
Sep 27, 2018 at 22:20 | history | answered | Matt Royal | CC BY-SA 4.0 |