VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: ruhanda on October 19, 2014, 10:26:48 AM

Title: [SOLVED] Need help on standard VM shipment method by weights
Post by: ruhanda on October 19, 2014, 10:26:48 AM
Hi All,

I'm using VM2.6.10 now starting add some shipment method but the result is not fit to Indonesian shipping model which is Shipping Cost = Shipment Cost * weight + Package Fee.
I found below function script in weight_countries.php file located in /plugins/vmshipment/weight_countries/ folder

function getCosts (VirtueMartCart $cart, $method, $cart_prices) {

      if ($method->free_shipment && $cart_prices['salesPrice'] >= $method->free_shipment) {
         return 0;
      } else {
         return $method->cost + $method->package_fee;
      }
   }

and I modify some mathematical expressions line  return $method->cost + $method->package_fee; to be return $method->cost * 10 + $method->package_fee; which 10 is represent weight, the result is fit with general Indonesia shipping methods. I need replace 10 with variable that get from order weight (total order weight)

unfortunately I'm not a programmer therfore I don't know how to get the order weight variable. I tried some variable that available on script such as $orderWeight but the result is only display package fee it's mean value of $orderWeight always 0 (zero).

if anyone can help me, would be appreciated.

PS: general shipping order weight is round up, if you can share how to do it, I would be appreciated.
Title: Re: Need help on standard VM shipment method by weights
Post by: GJC Web Design on October 19, 2014, 11:39:03 AM
there is a built in function for this

$Order_WeightKG = $this->getOrderWeight($cart, 'KG');// native func vmsplugin

but I think the free "rules" shipping plugin would be more useful for you
Title: Re: Need help on standard VM shipment method by weights
Post by: jenkinhill on October 19, 2014, 11:41:48 AM
Also have a look at the Advanced Shipping by Rules Plugin
http://open-tools.net/virtuemart-2-extensions/vm2-shipping-by-rules-plugin.html
Title: Re: Need help on standard VM shipment method by weights
Post by: ruhanda on October 19, 2014, 12:19:07 PM
GJC,
thanks for your respond, it's same with $orderWeight that I use and it's not working, you are right the rules shipping plugin is fit but it's not free.

jenkinhill,
Thanks for your suggestion. I installed the standard one but limited future because I cannot using mathematical expressions on free version, I have to use Advanced Shipping by Rules Plugin as you suggest.
I believe that plugin is answer all I need.

I thought it only add/modify simple command, I wish I understood the programming  :'(
Thanks any way guys
Title: [SOLVED] Need help on standard VM shipment method by weights
Post by: ruhanda on October 19, 2014, 14:53:40 PM
Hi All,

Finally I found it, below is little modification that I made, thanks to GJC.

function getCosts (VirtueMartCart $cart, $method, $cart_prices) {

      if ($method->free_shipment && $cart_prices['salesPrice'] >= $method->free_shipment) {
         return 0;
      } else {
         return ($method->cost * $this->getOrderWeight ($cart, $method->weight_unit)) + $method->package_fee;
      }
   }