Woocommerce: Add a dynamic Fee (surcharge) based on total product quantity
-
In Context: We sell temperature sensitive items by the dozen, to ship them I need to charge for packing materials (Styrofoam boxes, ice gels etc) depending on how many items they buy.
I pack 5 items per box and the fee for packing material must be $12, I was able to add the custom fee to my cart and checkout but it’s constant, I need it to be $12 for the first 5 items and add $12 more after every other five itemsso, if a client orders 15 items then the fee should be $36 and so on.
below is the code I am currently using to add the $12
addaction( 'woocommercecartcalculatefees','endohandlingfee' ); function endohandlingfee() { global $woocommerce; if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; $fee = '12'; $woocommerce->cart->add_fee( 'Packing Materials', $fee, true, 'standard' ); }
- The topic ‘Woocommerce: Add a dynamic Fee (surcharge) based on total product quantity’ is closed to new replies.