Login
Register

VirtueMart

WooCommerce

Others

Docs

Support

Blog

About

Forum

IMPORTANT ANNOUNCEMENT: Plugin development ceased, all plugins made available freely (GPL)

With great sadness we have to announce that we are ceasing development of all our VirtueMart, WooCommerce and Joomla plugins. Effective immediately, all our plugins -- even those that were paid downloads -- are made available for free from our homepage (GPL license still applies), but we cannot and will not provide any support anymore.

It has been a great pleasure to be part of the thriving development communities of VirtueMart as well as WooCommerce. However, during the last year it became painstakingly clear that in addition to a full-time job, a young family and several other time-consuming hobbies at professional level (like being a professional singer) the plugin development and the support that it requires is not sustainable and is taking its toll. It has been an honor, but it is now time to say good bye!

×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

SKU problem 03 Aug 2015 14:22 #1

  • wendij22
  • wendij22's Avatar Topic Author
Hello Reinold, hello everyone,

I have a problem regarding the Advanced Shipping tool and shipping based on SKU's. I will try and keep it as simple as possible.

Scenario 1:
Customer is buying only one product, which is a CD with the SKU Number D405B.

The code given in the back is:
Name="D405B"; "D405B" in SKUs; Shipping=0
Name=United Kingdom; 0.01<=Weight<2; 2*Weight+1
Name=Free shipping For Ebook; Weight==0; Shipping=0

It works perfectly of course. Keep reading.

Scenario 2:
Customer wants to buy the CD with SKU number D405B and a book (weight is below 2 kg, etc etc and therefore needs to pay some shipping costs towards it, in this case it doesn't matter how much).

In the back:
Name="D405B"; "D405B" in SKUs; Shipping=0
Name=United Kingdom; 0.01<=Weight<2; 2*Weight+1
Name=Free shipping For Ebook; Weight==0; Shipping=0

System says:
No shipping for the CD, but doesn't take the book into account. So no shipping at all, but the customer should pay the shipping for the book.

My question is: how can I write the code in such a way that it reads and/and? Especially the first two lines "D405B" and "United Kingdom"?

On this moment it is written like if/if. So if system is picking up CD, then no shipping and the loop stops there, but it should continue with the next line.

Could anyone assist me please?

I thank you in advance for your help.

Kindest regards,

Wendy

SKU problem 07 Aug 2015 19:53 #2

Dear Wendy,
Your observation is correct: The plugin stops at the first rule that matches and offers the shipping rate specified by that rule. This is one of the key assumptions of how the plugin works. This gives it a lot of power, but you have to keep this in mind when you design the rules.
The other thing is that all rules are applied per cart, not per product. So once a shipping rate is determined, it does not make sense to look at the next rule.

The logic of your rules as you wrote them can also be expressed as:
1) If the CD with SKU D405B is bought (possibly among other items), then shipping is free for the whole order.
2) Otherwise, calculate the shipping based on weight (if weight between 0.01 and 2).
3) Finally, if none of the above applies, and the weight is zero, offer free shipping.

As you can imagine, to make things work the way you like, you need to rearrange the rules a bit. If I understand you correctly, you want to exclude only the CD from the weight-based rule, but not other articles. Does the CD have a weight configured?

- Case 1: CD does NOT have a weight configured => Simply put the weight-based rule first.
Name=United Kingdom; 0.01<=Weight<2; 2*Weight+1
Name="D405B"; "D405B" in SKUs; Shipping=0
Name=Free shipping For Ebook; Weight==0; Shipping=0
The CD won't contribute to the Weight, so the cost is calculated correctly. And if the customer buys only the CD, the weight will be 0 and the condition on the weight in the first rule will not match, so the second rule will be considered in that case.

- Case 2: The CD does have a weight configured => You cannot look at the Weight variable, because that contains the weight of the CD, too. Thus, you have to define your own custom weight variable that contains the weight with the CD's weight subtracted:
Variable=MyWeight; Value=Weight-evaluate_for_products(Weight, "D405B")
Name=United Kingdom; 0.01<=MyWeight<2; 2*Weight+1
Name="D405B"; "D405B" in SKUs; Shipping=0
Name=Free shipping For Ebook; Weight==0; Shipping=0
The logic is similar to the first case, just that you use the MyWeight variable, where you have subtracted the weight of the CD from the total weight of the cart's contents.

Best regards,
Reinhold

[SOLVED] SKU problem 10 Aug 2015 13:23 #3

  • wendij22
  • wendij22's Avatar Topic Author
Thanks for helping. Case 1 was the most useful and it is working perfectly. Thank you.
  • Page:
  • 1