VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: liquid.ideas on August 15, 2013, 00:42:45 AM

Title: Product weight multiplied by shipping fee - SOLVED
Post by: liquid.ideas on August 15, 2013, 00:42:45 AM
Hi Guys,

I know there must be a way to do it, I would like to have a little shipping calculator on the fly, so I thought I could call weight <?php echo $product_weight ?> multiplied my shipping fee, but I dont know how to call this, any ideas?

Thanks in advance for anything anyone might come up with!
Title: Re: Product weight multiplied by shipping fee
Post by: Maxim Pishnyak on August 15, 2013, 10:36:36 AM
Quote from: LuukDriessen on January 25, 2013, 12:38:32 PM
I did some research.

I found/knew that <?php echo $product->product_weight ?> is used to show the weight of the product.
And did you do some research. Did you check these sticked threads about template overrides in this forum section?
Title: Re: Product weight multiplied by shipping fee
Post by: liquid.ideas on August 15, 2013, 17:17:05 PM
Yup that is where I found how to call the weight from Banquets awesome posts that I always go back to :)

What I want to do on the product page is somehow display weight x shipping dont need it ajax I dont think, basically there are two shipping rates so it would be
weight x shipping
and
weight x shipping + 2% insurance fee

Any ideas?
Title: Re: Product weight multiplied by shipping fee
Post by: Maxim Pishnyak on August 15, 2013, 18:55:48 PM
So are you able to show weight or not?
Title: Re: Product weight multiplied by shipping fee
Post by: liquid.ideas on August 16, 2013, 13:17:32 PM
Hi Maxim,

thanks foe being so patient with me :) yes I can show the weight I just cant show what the shipping would cost!
Title: Re: Product weight multiplied by shipping fee
Post by: Maxim Pishnyak on August 16, 2013, 20:27:53 PM
Quote from: liquid.ideas on August 16, 2013, 13:17:32 PM
... what the shipping would cost!
Thank you!

And how much is the shipping would be?
Title: Re: Product weight multiplied by shipping fee
Post by: liquid.ideas on August 17, 2013, 08:59:35 AM
Hi Maxim,

It would be R70 for the first ten kilograms, and R10 per kilogram thereafter :)
Title: Re: Product weight multiplied by shipping fee
Post by: Maxim Pishnyak on August 18, 2013, 12:17:31 PM
Oh come on, it's fair easy to challenge php IF command for this. Try to construct and test something and I'll help you during your probes.
Title: Re: Product weight multiplied by shipping fee
Post by: liquid.ideas on August 18, 2013, 15:12:42 PM
Hi Maxim,

I can do something like this and works:


$result = $this->product->product_weight;
$rshipping = 70 ;
$count =+ 3.5 ;

if ($result <=2) {echo "Shipping Estimate Regional:<br />" .$rshipping;}
elseif ($result++) {echo "Shipping Estimate Regional: <br />" .$rshipping + $count;}


But that only returns "3.5" if the weight is three, I am not sure how to say for example "if result is +1 then add 3.5 to rshipping, I know it is something that is probably blindingly obvious but cant work it out
Title: Re: Product weight multiplied by shipping fee
Post by: Maxim Pishnyak on August 18, 2013, 15:49:27 PM
Quote from: liquid.ideas on August 17, 2013, 08:59:35 AM
ten kilograms
if ($result <=10) {echo "Shipping Estimate Regional:<br />" .$rshipping;}
else {echo "Shipping Estimate Regional: <br />" . ($rshipping + 10*($result-10)) ; }
Title: Re: Product weight multiplied by shipping fee - SOLVED
Post by: liquid.ideas on August 18, 2013, 16:05:13 PM
Thank you Thank you THANK YOU Maxim!!

Yes, this works like a bomb, for anyone else you may get a syntax error just add in a ; before closing bracket
Title: Re: Product weight multiplied by shipping fee - SOLVED
Post by: Maxim Pishnyak on August 19, 2013, 12:27:47 PM
Thank you for pointing this, Liquid. And ... you are welcome!