php - How to set a shipping cost by item in Woocommerce
Get the solution ↓↓↓In Woocommerce, when I add multiple products in cart, the shipping only applies to to 1 product. How should I change that to apply the cost to each item?
Like in the following image, the shipping cost for printer is applied but the LCD monitor is not.
How to set a shipping cost by item in Woocommerce?
Answer
Solution:
In the Woocommerce Shipping Settings for "Flat rate" Shipping Method, there is many ways to get dynamic settings based on:
- Item quantity, using
{-code-1}
argument - Total item cost, using
{-code-2}
argument - A fee, using
{-code-3}
argument with additional parameters{-code-4}
,{-code-5}
and{-code-6}
You can also use{-code-7}
,-
,*
and/
operators and parenthesis.
Here are some example:
{-code-1}*2
- Cost by item4{-code-7}({-code-1}*2.5)
- Initial cost with an additional cost by item[fee {-code-4}age='10' {-code-5}='' {-code-6}='20']
- Percentage fee limited to a max amount[fee {-code-4}age='10' {-code-5}='4' {-code-6}='']
- Percentage fee with a minimal cost
Related thread: Set Minimum item cost in Woocommerce Shipping method rates
Advanced shipping cost customizations:
It's possible to customize even more shipping costs using woocommerce_package_rates
filter hook.
See all StackOverFlow related threads using woocommerce_package_rates
filter hook.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: call to undefined function str_contains()
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.