VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: gzamanis on July 03, 2018, 09:02:54 AM

Title: Enable shipment method if ALL products in cart are in certain category
Post by: gzamanis on July 03, 2018, 09:02:54 AM
Hi,
I need to be able to offer free shipping for certain categories, only if all products of those categories are in cart. In case of mixed products, the standard rate should be applied. Out of the box the plugin works with "if ANY product in cart in a certain category".

I've checked the code in weight_countries.php and in line 320 there is this comment:
//if all products in a certain category, display the shipment

but I don't see any code right after it.

Any insights on how to change the logic of this plugin (it's the standard plugin coming with VM aio)?
Title: Re: Enable shipment method if ALL products in cart are in certain category
Post by: Jörgen on July 03, 2018, 09:42:23 AM
Hello

You have three choices:
Option nr 3 is probably the best, but nr 2 could work.

regards

Jörgen @ Kreativ Fotografi
Title: Re: Enable shipment method if ALL products in cart are in certain category
Post by: gzamanis on July 03, 2018, 09:53:08 AM
I was looking for some kind of tinkering, but I  don't know what to change in the code in order to switch "ANY" to "ALL".

That's what I was hoping to find in here actually..
Title: Re: Enable shipment method if ALL products in cart are in certain category
Post by: Studio 42 on July 03, 2018, 17:28:57 PM
See https://shop.st42.fr/en/tools/shipment-rules.htm
You have many way to filter, not only inlcuding/excluding categories. Eg; customfield, SKU ... so with this plugin you can solve your problem
Title: Re: Enable shipment method if ALL products in cart are in certain category
Post by: Jörgen on July 03, 2018, 19:12:30 PM
Thank You Patrick

Didn´t think about that You might have one that would work.

regards

Jörgen @ Kreativ Fotografi
Title: Re: Enable shipment method if ALL products in cart are in certain category
Post by: Typhoon365 on July 05, 2018, 07:21:45 AM
You could also look at this "Shipping by Rules" plugin by Open Tools, we use it on our site and find it quite flexible with the rules you can implement.

https://open-tools.net/component/content/article/22-virtuemart-2-extensions/46-rules-examples-for-shipping-by-rules.html (https://open-tools.net/component/content/article/22-virtuemart-2-extensions/46-rules-examples-for-shipping-by-rules.html)
Title: Re: Enable shipment method if ALL products in cart are in certain category
Post by: gzamanis on July 09, 2018, 22:43:26 PM
Ok, I''ve written a script to hide a certain shipping method in One Page Checkout, but I do not know which file to put it in. I know it must have something to do with AJAX, since this is how the cart is recalculated after each change in shipping or payment method..