Login
Register

VirtueMart

WooCommerce

Others

Docs

Support

Blog

About

Shipping By Rules for WooCommerce

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:

Flat Rate for one category, rest based on quantity 06 Jul 2017 16:15 #1

  • WendyWestbrook
  • WendyWestbrook's Avatar Topic Author
I am trying to create rules that will charge only .99 for shipping of a gift card, and then the rest of the items would be based on quantity purchased.

These are the rules I'm currently using and no matter what, the gift card is included in the number of items:

Variable=GiftCards; Value=evaluate_for_categories(Articles, 45)
Variable=OtherItems; Value=Articles-GiftCards
Comment="Only gift card"; GiftCards==Articles; Shipping=0.99
OtherItems<=1; Shipping=8.24
OtherItems<=2; Shipping=13.15
OtherItems<=3; Shipping=18.06
OtherItems<=4; Shipping=21.31
OtherItems<=5; Shipping=23.31
OtherItems<=6; Shipping=25.31
OtherItems<=7; Shipping=27.31
OtherItems<=8; Shipping=29.31
OtherItems<=9; Shipping=31.31
OtherItems<=10; Shipping=33.31
OtherItems<=11; Shipping=35.31
OtherItems<=12; Shipping=37.31

Results are purchasing a gift card by itself charges $8.24 for 1 card, and if purchased with other items, it increased the value of items purchased according to the OtherItems rules. So 1 gift card, and 1 other item will result in $13.15 for shipping. It should be 1 gift card = $.99 for shipping, 1 gift card + 1 other item results in $9.23 shipping ($8.24 + $.99). Adding other items on their own, without gift card, works as expected.

I realize I may have done this completely wrong. Can you please advise on what I'm doing incorrectly?

Thank you!

Flat Rate for one category, rest based on quantity 08 Jul 2017 18:24 #2

Dear Wendy,
In WooCommerce, the categories are identified by their category SLUG, so the evaluate_for_categories should not use any category ID, but rather SLUG you used in the category definition (this makes the rule much more readable than in other e-commerce systems where you need to use a numeric ID). Assuming your category has SLUG "giftcards", the first variable definition would be:
Variable=GiftCards; Value=evaluate_for_categories(Articles, "giftcards")

If that does not help, please insert the following debug rule to print out the long list of all available variables after the second variable definition (the OtherItems):
Message="<pre>All variables: {Values_Debug}</pre>"; Value=0
If you now go to the checkout, the plugin should print out all available variables and their values. In particular, you should check the values of GiftCards, OtherItems, but also the list of all categories in the cart.

Best regards,
Reinhold

Flat Rate for one category, rest based on quantity 11 Jul 2017 15:00 #3

  • WendyWestbrook
  • WendyWestbrook's Avatar Topic Author
Thank you so much! That did work.

I have another question about the same set of rules. I need it to add the value of each gift card (if they buy 1, it's $.99 - if they buy 2, it's $1.98) in addition to the other items. It seems that when other items are purchased, it no longer includes the gift card shipping costs.

Can you tell me what to change to make that happen?

Thank you!

Flat Rate for one category, rest based on quantity 15 Jul 2017 18:18 #4

Dear Wendy,
Yes, in your current rules, the gift cards are only used in the "Only gift cards" rule. To add the gift card-shipping (.99 per card) to the shipping costs automatically, you basically have to approaches:

1) Use a custom variable to store the gift card shipping and add it to each shipping rate:
Variable=GiftCards; Value=evaluate_for_categories(Articles, "giftcard-SLUG")
Variable=OtherItems; Value=Articles-GiftCards
Variable=GiftCardShipping; Value=GiftCards*0.99
Comment="Only gift card"; GiftCards==Articles; Shipping=0.99
OtherItems<=1; Shipping=8.24+GiftCardShipping
OtherItems<=2; Shipping=13.15+GiftCardShipping
...

2) Use the ExtraShippingCharge feature to specify an additional shipping cost that will be automatically added to the result of all subsequent rules (of course, only to the matching rule):
Variable=GiftCards; Value=evaluate_for_categories(Articles, "giftcard-SLUG")
Variable=OtherItems; Value=Articles-GiftCards
Comment="Only gift card"; GiftCards==Articles; Shipping=0.99
ExtraShippingCharge=GiftCards*0.99
OtherItems<=1; Shipping=8.24
OtherItems<=2; Shipping=13.15
...
This approach is faster to implement, but harder to read if you look at the rules in a few years, as it is easy to overlook.
Please note that the extra shipping charge must be placed after the gift-card-only case, but before the OtherItems<=1 rule, because the extra charge should not apply to gift-card-only orders, but should be added to all remaining rules.

Best regards,
Reinhold

PS: In the gift-card-only case, do you want to have fixed shipping costs of 0.99, or do you want 0.99 per card? Your current rules are a flat-rate of 0.99, irrespective of the number of gift cards ordered. To charge 0.99 shipping per gift card, you need to adjust your gift-card-only rule to Shipping=0.99*Articles

Flat Rate for one category, rest based on quantity 15 Jul 2017 23:45 #5

  • WendyWestbrook
  • WendyWestbrook's Avatar Topic Author
You are AWESOME!!! That worked perfectly. (I used the code from approach #1, and adjusted to charge $.99 shipping per each gift card)

This was exactly what I needed to make this work.

Thank you so very much. I appreciate your help.

Have a GREAT day! :)

[SOLVED] Flat Rate for one category, rest based on quantity 15 Jul 2017 23:46 #6

  • WendyWestbrook
  • WendyWestbrook's Avatar Topic Author
Problem solved.
  • Page:
  • 1