Calculate shipping based on total AFTER fees
-
Hi, I’m needing help with a small but major issue that I can’t seem to figure out. While the function is much more complex, I’ve broken it down to only a few lines to aid in reproducing the issue.
Basically my issue is exactly as this, but the fix does not solve my problem. I have a fee that subtracts 5% from the subtotal if you order $300 or more. My code is this:
add_action( 'woocommerce_cart_calculate_fees','woocommerce_custom_surcharge' ); function woocommerce_custom_surcharge() { global $woocommerce; $woocommerce->cart->add_fee( '5% off $300 or more', 0.05 * $woocommerce->cart->subtotal * -1, true, ''); }
The fee itself works, however I’m using the WooCommerce table rate shipping plugin, and the difference between the two prices should have bumped the table rate down a price break in cost.
The suggestion in the previously mentioned thread suggests instead using woocommerce_calculate_totals, however it breaks the
add_fee()
function and the fee is stuck at $0.00 no matter what I do.$woocommerce->cart->subtotal
is still being retreived, but the function itself just seems to no longer work.Not sure what needs to be done to get this working. Any help is appreciated, or if this is an issue with the plugin I’m using and not vanilla WooCommerce.
- This topic was modified 6 years, 3 months ago by .
- This topic was modified 6 years, 3 months ago by .
The page I need help with: [log in to see the link]
- The topic ‘Calculate shipping based on total AFTER fees’ is closed to new replies.