[SOLVED] Need help on standard VM shipment method by weights

Started by ruhanda, October 19, 2014, 10:26:48 AM

Previous topic - Next topic

ruhanda

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.

GJC Web Design

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
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

ruhanda

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

ruhanda

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;
      }
   }