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:

Can someone help me work out the formula? 30 Aug 2013 09:29 #1

  • liquid.ideas
  • liquid.ideas's Avatar Topic Author
Hey I bought the advanced shipping by rules plugin but I cant work out the formula!!

Basically, I want a shipping fee that is weight less than or equal to 5 is R50 and R3.50 per kilogramme there after, the next shipping method I need is same as the above but with 2% of total cos of cart as shipping insurance.

If I do it in php the first one is as follows:

<?php
$result = $this->product->product_weight;
$mshipping = 50;

if ($result <=5) {echo "Shipping Estimate Main Centre: R" .$mshipping;}
else {echo "Shipping Estimate Main Center: R" . ($mshipping + 3.50*($result-5)) ;}

?>

But I am battling to convert this into your plugin, could you possibly help?

Can someone help me work out the formula? 02 Sep 2013 01:02 #2

If you want the user to choose from shipping without insurance and shipping with insurance, you need to set up two shipping methods with the advanced Shipping by Rules plugin. The first ("Shipping without Insurance") will have the two rules
Weight<=5; Shipping=50
Weight>5; Shipping=ceil(Weight-5)*3.5
and the second ("Shipping with Insurance") will have the rules
Name="Below 5kg"; Weight<=5; Shipping=50+0.02*Amount
Weight>5; Shipping=50+ceil(Weight-5)*3.5 + 0.02*Amount

Of couse, you can try to combine the below and above 5kg rules into one by using max(weight-5,0) in the rule:
Shipping=50+ceil(max(Weight-5,0))*3.5 + 0.02*Amount
The max function will return 0 for all orders below 5 kg, and the kg above 5kg for all other orders. So both cases (<5 and >5kg) are correctly handled.
  • Page:
  • 1