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:

How to write condition that checks for empty value 03 Feb 2017 11:38 #1

  • shopoftoys
  • shopoftoys's Avatar Topic Author
Hi,

How do we check for an empty value (no value defined) for the Virtuemart product packaging field of a product ?

We are writing a rule that uses the TotalPackaging field in a calculation for working out shipping charges for the total order for Express Postage. (We are using the Advanced Shipping Rules)

But I need a rule that excludes this shipping method if the order contains any products where we haven't defined the Virtuemart "Product Packaging" size for a product. (We have so many products, we haven't got around to defining package size for each of them and also want to cautious if we forget to populate the field when adding new products, would like to exclude it from our express post shipping rule)

Tried using a rule like below hoping that MinPackaging==0 would catch a product with empty product packaging value but didn't work.
Name=Product weight NOT defined; MinPackaging==0;NoShipping
Name=Express Post; ShippingWithTax=TotalPackaging*5.00

Appreciate any assistance, thank you.

How to write condition that checks for empty value 19 Feb 2017 13:58 #2

Dear ShopOfToys,
Unfortunately, there is currently no way I'm aware to check whether a field is defined at all. In PHP, internally it has a value of Null, but the plugin does not have that value implemented, so you can't check for Null (becuase "Null" would be a string and Null without quotes would be interpreted as a variable that does not exist).

The only way I can think of is that you implement a custom plugin to extend the shipping by rules plugin: open-tools.net/virtuemart/advanced-shipp...ipping-by-rules.html

The last section on that page documents the API, the first few plugins can be used as sample code for implementation.
In such a custom plugin you have full access to the whole cart data structure in PHP, so you can loop through all products in the cart and check whether product packaging has a value set or not. If not,you can e.g. set a custom variable that you use in your rules to exclude the order from shipping and print out a warning.

Sorry that I can't provide an easier way....

Best regards,
Reinhold

How to write condition that checks for empty value 24 Feb 2017 23:46 #3

  • shopoftoys
  • shopoftoys's Avatar Topic Author
Thanks Reinhold for looking into this and your response.

For now, think we have worked around it okay by checking MinPackaging < 0.0001

Can understand the complexity in checking for the Null value.

[SOLVED] How to write condition that checks for empty value 24 Feb 2017 23:46 #4

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