Enable shipment method if ALL products in cart are in certain category

Started by gzamanis, July 03, 2018, 09:02:54 AM

Previous topic - Next topic

gzamanis

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)?

Jörgen

Hello

You have three choices:

  • Hack the shipment plugin
  • Make an override
  • Create a copy of the plugin under new name and add your new functions
Option nr 3 is probably the best, but nr 2 could work.

regards

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

gzamanis

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..

Studio 42

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

Jörgen

Thank You Patrick

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

regards

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Typhoon365

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

gzamanis

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..