Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDimi Wei
217 PointsShipping formula (Woccommerce)
I ve got a question concerning the shipping formula (>> Flat Rate Shipping >> Costs)
Ho exactly can I use these parameters: [qty], [cost], [fee] ??
Thanks.
12 Answers
Jake Lundberg
13,965 PointsYou would need additional information in order to complete the formula as your parameters do not include the cost of shipping...
Dimi Wei
217 PointsSo is it possible to define several options, e.g.:
- if the order size is 1-5 items = 5 dollars
- If the order size larger than 5 then, its 10 dollars ...?
Jake Lundberg
13,965 Pointsabsolutely. I'm not sure what kind of project you are working, or what exactly you are doing, but yes, you could easily do that.
Dimi Wei
217 PointsAnd how exactly can I set this up ?
Jake Lundberg
13,965 PointsDepends on what you are trying to do...
Dimi Wei
217 Pointslets say, I m trying to set up the above example. 1-5 items = 5 dollars , more than 5 items = 10 dollars How do I write the formula? It is menitoned but I cannot find any tutorials on this.
Jake Lundberg
13,965 Pointsthat would be a simple if-else statement:
if(quantity > 5) {
shipping = 10;
} else {
shipping = 5;
}
Dimi Wei
217 Pointsso the code goes diractly into a php file ? I thought that is supposed to be typed in the box with the shipping cost price.
Jake Lundberg
13,965 Pointsagain, it all depends on what you are trying to accomplish. I am only guessing it is an order form for a customer. If that is the case, then you don't want them entering that information into the form themselves. You would handle that in the code behind the scenes with php or javascript or whatever you are using...
Dimi Wei
217 PointsI was actually talking about the specific formula that is mentioned here:
https://dl.dropboxusercontent.com/u/10626022/example.jpg
Woocommerce >> Settings >> Flat Rate Shipping
Jake Lundberg
13,965 PointsMy apologies, I misunderstood. Looking at the picture, it does not appear you are able to change the shipping cost based on the quantity. Looks like shipping is a flat rate based on this form...So, No, you will not be able to adjust the shipping cost as you have requested unless you are able to modify the code.
Dimi Wei
217 PointsOh OK, thank you very much.