This PHP code targets specific products enabling the store owner to add a fee based based on quantity. In this example, the code targets a specific product and adds a fee of 3.60 to the cart totals for each item.
The fee is added to the cart totals and checkout page.
The fee is calculated using an PHP arithmetic operator * for multiplication, fee x quantity.
There’s only 2 steps :
1. Copy and paste the PHP code to your child themes functions file or custom functionality plugin.
2. Set your product id'(s) on line 15 and the fee per unit on line 28.
You can also modify the fee text.