Login
Register

VirtueMart

WooCommerce

Others

Docs

Support

Blog

About

Shipping by Rules for VirtueMart

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:

Overriding Shipping Rules 21 Feb 2017 09:51 #1

  • slumley
  • slumley's Avatar Topic Author
We want to overwrite shipping rules. Certain manufacturers are set up that only the courier option is available.
Item A has only courier option set up. Item B has no shipping rules added (collect from office, free delivery, post office etc).
When we add item A and B to the cart all the shipping rules become available. how do we overwrite the configuration so that if Item A and B is added the shipping rules we can overwrite item B to also only show the courier option?
Is there a line of code that we can use to implement this override.

Below is our current code:
Comment=Tudortech; Condition=issubset(Manufacturers, list(561)); Amount<1300; NoShipping
Condition=issubset(Manufacturers, list(78, 82, 18, 64, 86, 94, 547, 560, 571)); NoShipping
Shipping=0

Overriding Shipping Rules 28 Feb 2017 03:24 #2

  • Mclernons
  • Mclernons's Avatar
I'm in need of similar. Only way I'm seeing it right now is to custom write a shipping plugin.

Overriding Shipping Rules 04 Mar 2017 18:06 #3

Dear Slumley, dear McLernons,
Do I understand you correctly that you want the following:
- You have two or more shipping methods set up: "Courier" and "Other method"
- If item A (from a given manufacturer, say manuracturer ID 123) is in the cart, then only "Courier" should be offered, but no other
- Item B has no restrictions, but if item A is added, then only Courier should be allowed.

If this is what you want, you'll have to create two (or more) shipping methods:

1) Method "Courier": This method should be offered for all orders (no restriction on manufacturer):
Name="Courier is always offered"; Shipping=1234

2) Method "Other method": Only offered if the cart does not contain items from manufacturer 123
Comment="not offered for manuf. 123"; 123 in Manufacturers; NoShipping
name="Free shipping for all other orders"; Shipping=0


Now, if an order contains only item B, both methods will be offered for selection. However, if the order also contains an item from manufacturer 123, then the "Other method" will not be offered and only "Courier" will be shown for selection by the customer.

Is this what you want?

Best regards,
Reinhold

Overriding Shipping Rules 06 Mar 2017 09:33 #4

  • slumley
  • slumley's Avatar Topic Author
Hi Reinhold.

Thanks for your reply, we have tried your rule but I think there is a part missing, let me explain again:

We have various products that ship from different warehouses.

We have setup various shipping methods:
1: Post Office
2: Collect from Office
3: Couriers

Let's take two products as an example.

Ryobi (ID: 547) Can only have " Couriers" as shipping method.
Bosch Tool: (ID: 526) No shipping restrictions on this product.

When you add a Ryobi (ID: 547) and a Bosch Tool: (ID: 526) to the cart it gives you all the shipping options but it should not, In this case is should only give you the courier option.
you can visit www.4home.co.za and try it yourself.

Overriding Shipping Rules 09 Mar 2017 04:07 #5

  • Mclernons
  • Mclernons's Avatar
I also just tried this on my local server.

Added one item to the cart which needed to be quoted, both methods still showed.

Tried the code as a new rule and just for a country zone.

Slumley I've got the exact same issue as you.
Products coming from various warehouses with their own courier company which charge different fees based upon metrol, rural, and if it's CBD as well.

My example. Furniture has to be quoted, then you put a shredder or another machine in the cart and both methods show still. Only one method must show.



Attachments:

Overriding Shipping Rules 08 Apr 2017 19:15 #6

Dear Slumley,
To exclude certain products from one method, you simply have to adjust the condition from the "Other method" in my response above (open-tools.net/forum/shipping-by-rules-p...ping-rules.html#7863) to
Comment="Ryobi and other products not allowed for Collect from Office"; Condition=contains_any(Manufacturers, 547); NoShipping
name="Free shipping for all other orders"; Shipping=0
Using contains_any is the same as "547 in Manufacturers", except that contains_any allow you to give multiple manufacturers that are not allowed in the method. Please notice that you'll have to insert the correct manufacturer IDs (my example rules typically use some dummy IDs like 123 or 111).

Best regards,
Reinhold

Overriding Shipping Rules 08 Apr 2017 19:19 #7

Dear Slumley,
Coming back to the rules of your initial post, the correct way to insert all your manufacturer IDs into my sample rules are:
Comment=Tudortech; Condition=contains_any(Manufacturers, 561); Amount<1300; NoShipping
Condition=contains_any(Manufacturers, 78, 82, 18, 64, 86, 94, 547, 560, 571); NoShipping
Shipping=0
(Your original rule using issubset actually meant that shipping was denied if ONLY those manufacturers were in the cart. As soon as any other manufacturer was in the cart, your rule allowed shipping... The contains_any function in my eyes is much easier to understand, so I would recommend using that instead of issubset).

Best regards,
Reinhold

Overriding Shipping Rules 08 Apr 2017 19:36 #8

Dear Mclernons,
Could you post your exact rules for the two shipping methods? It's quite hard to figure out what the problem is without knowing your exact rules. Usually, some fresh pair or eyes one can quickly spot tiny mistakes in rule sets that cause misbehavior.

Best regards,
Reinhold

Overriding Shipping Rules 10 Apr 2017 11:40 #9

  • slumley
  • slumley's Avatar Topic Author
Hi

When I added "Condition=contains_any" to the Post office rule then it shows even if a add just the Ryobi item to the cart, that will not work.


Perhaps you can understand by me explaining in the following way:

We have three shipping methods using "rules_shipping_advanced"

1: Courier
2: Post office.
3: Collect from office.

now let's take two products as an example.

Ryobi (ID: 547) Can only have " Couriers" as shipping method.
Bosch Tool: (ID: 526) No shipping restrictions on this product.

If a customer orders the Bosch item (ID: 526) there is no restrictions and the customer is shown all 3 shipping options.

If a customer orders the Ryobi item (ID: 547) the rules only shows the Courier option. (This is correct)

Courier Rule:
Comment=Free Del ACT + Kovdor + Dyson; Name=Free Delivery; Condition=issubset(Manufacturers, list(537,529,17)); Shipping=0
Comment= Casio + CDG; Name=Free Delivery; Condition=issubset(Manufacturers, list(94,520)); Shipping=0;400<=Amount;Shipping=0
Comment= Stingray +Kenwood +Philips+FFIT; Name=Free Delivery; Condition=issubset(Manufacturers, list(9,72,21,572)); Shipping=0;800<=Amount;Shipping=0
Comment=Mustek; Name=Free Delivery; Condition=issubset(Manufacturers, list(8)); Shipping=0;3500<=Amount;Shipping=0

Definition=FuelPerc; Value=1.35
Definition=LocalRate; Value=3
Definition=RegRate; Value=8.3

Name=Local under 5KG) ({Weight}; Weight<=5; 0001<=ZIP<=0002 OR 0005<=ZIP<=0008 OR 0010<=ZIP<=0012 OR 0014<=ZIP<=0017 OR ZIP==0019 OR 0023<=ZIP<=0024 OR 0026<=Z.......

Post office Rule:
Condition=issubset(Manufacturers, list(18, 64, 78, 82, 86, 547, 560, 571, 572)); NoShipping
Name={Weight}; Weight<=0.5; Shipping=44.60 + amount*0.03
Name={Weight}; 30>Weight>0.5; Shipping=44.60 + Weight*6 + amount*0.03|


Collect from office Rule:
Comment=Tudortech; Condition=issubset(Manufacturers, list(561)); Amount<1300; NoShipping
Condition=issubset(Manufacturers, list(78, 82, 18, 64, 86, 94, 547, 560, 571, 572)); NoShipping
Shipping=0


Now the problem happens when you add both items into the cart, it shows all 3 shipping methods.

What the rule needs to do is NOT show the Post Office and Collect from office when these two product ID's are added together.

Is there a rule that we can add to the "Post Office" and "Collect from office" to hide the two shipping options when (ID: 547 and ID: 526) is present?

Please visit www.4home.co.za/ and try it for yourself.

Overriding Shipping Rules 22 Apr 2017 21:01 #10

Dear slumley,
Thank you for the sample rules. If I understand you correctly, the "Courier" Ruleset works just as you want it (i.e. it is always offered with the correct shipping costs).

The Post office and Collect from office rules, on the other hand, should not be offered at all if any product from manufacturers 78, 82, 18, 64, 86, 94, 547, 560, 571 or 572 is in the cart. If this is the correct understanding, then your condition using issubset is wrong. In particular, your issubset means that the rule will not be offered if ONLY those prohibited manufacturers are in the cart. As soon as any other manufacturer is in the cart, the method will be offered.
On the other hand, a condition=contains_any(Manufacturers, 78, 82, 18, 64, 86, 94, 547, 560, 571, 572) will return to true if at least one of the given manufacturers is in the cart, but also potentially other manufacturers. If I understand you correctly, this is the very case where you want to hide your method (at least one of these manufacturers, but possibly also other manufacturers in the cart).

Have you actually tried my rules e.g. for "Collect from Office':
Comment=Tudortech; Condition=contains_any(Manufacturers, 561); Amount<1300; NoShipping
Condition=contains_any(Manufacturers, 78, 82, 18, 64, 86, 94, 547, 560, 571, 572); NoShipping
Shipping=0

If you add only one product from manufacturer Ryobi (id 547) to the cart, then the contains_any of the second rule will evaluate to TRUE and thus the second rule should prevent this method from being offered. Do you observe any other behavior?

If so, we'll need to start debugging the values of the Manufacturers variable (open-tools.net/documentation/advanced-sh...merce.html#debugging). In that case, please simply prepend the following rule to your rulesets, which will print out the values of all available variables:
Message=All variables: <pre>{Values_Debug}</pre>; Value=0
Of particular interest is the value of the manufacturers list. Could you paste that here?

Best regards,
Reinhold
  • Page:
  • 1