VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: ovg on September 30, 2015, 19:59:43 PM

Title: Add packaging weight to card
Post by: ovg on September 30, 2015, 19:59:43 PM
Hi Guys,

I want to add packaging weight to the total weight of all the products in the basket.

Example basket:

2 pieces of product 1 (20gram a piece) 40 gram
3 pieces of product 2 (80 gram a peice) 240 gram
Total weight of products 280 gram.

Than add 90 gram of packaging.
Shipping methode must use 370 gram to select the correct shipping methode.



I think for this I must hack the vmpsplugin.php. I found this code:

protected function getOrderWeight (VirtueMartCart $cart, $to_weight_unit) {

static $weight = array();
if(!isset($weight[$to_weight_unit])) $weight[$to_weight_unit] = 0.0;
if(count($cart->products)>0 and empty($weight[$to_weight_unit])){

foreach ($cart->products as $product) {
$weight[$to_weight_unit] += (ShopFunctions::convertWeightUnit ($product->product_weight, $product->product_weight_uom, $to_weight_unit) * $product->quantity);
}
}
return $weight[$to_weight_unit];
}


What can I do to add the extra 90 gram?

Look forward to your help!

Kind Regards.
Title: Re: Add packaging weight to card
Post by: GJC Web Design on September 30, 2015, 21:29:13 PM
If you echo out the $cart is the packing weight there?

or do you mean a standard 90gram to any shipment?

and as always

http://forum.virtuemart.net/index.php?topic=104795.0

http://forum.virtuemart.net/index.php?topic=79799.0
Title: Re: Add packaging weight to card
Post by: ovg on October 01, 2015, 10:00:11 AM
Hi GJC,

Sorry for the lost info: It's about VM 3.0.10 en J3.4.4.

Indeed I mean a standard 90 gram to any shipment!

Can you help me with that? Hope so ;-)

Kind regards
Title: Re: Add packaging weight to card
Post by: GJC Web Design on October 01, 2015, 10:47:20 AM
Hmmm .. I don't know-- never been asked or tried

I guess add this weight in the shipping method after the getOrderWeight() is called

Could be an additionally parameter.. maybe someone else has a better idea..
Title: Re: Add packaging weight to card
Post by: ovg on October 01, 2015, 11:33:57 AM
I've solved it with this code:

return $weight[$to_weight_unit] + 0.092;

Happy ;-)
Title: Re: Add packaging weight to card
Post by: GJC Web Design on October 01, 2015, 13:01:03 PM
would prefer in the shipping plugin.. this will get over written every up date
Title: Re: Add packaging weight to card
Post by: ovg on October 01, 2015, 13:10:04 PM
Agree!!!