Author Topic: Enable shipment method if ALL products in cart are in certain category  (Read 214 times)

gzamanis

  • Beginner
  • *
  • Posts: 3
  • A beginner
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

  • Global Moderator
  • Full Member
  • *
  • Posts: 1541
    • Kreativ Fotografi
  • VirtueMart Version: 3.2.12
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.8.3
Virtuemart 3.2.12
Olympiantheme Hera (customized)

gzamanis

  • Beginner
  • *
  • Posts: 3
  • A beginner
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

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3154
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
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

  • Global Moderator
  • Full Member
  • *
  • Posts: 1541
    • Kreativ Fotografi
  • VirtueMart Version: 3.2.12
Thank You Patrick

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

regards

Jörgen @ Kreativ Fotografi
Joomla 3.8.3
Virtuemart 3.2.12
Olympiantheme Hera (customized)

Typhoon365

  • Beginner
  • *
  • Posts: 35
  • VirtueMart Version: 3.2.2
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

  • Beginner
  • *
  • Posts: 3
  • A beginner
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..