VirtueMart Forum

VirtueMart 1.1.x [ Old version - no longer supported ] => Questions VM 1.1 ( the only active board for the old version) => Topic started by: MTechMgr on May 11, 2016, 09:11:04 am

Title: Product shipping cost estimation
Post by: MTechMgr on May 11, 2016, 09:11:04 am
Hello. I have made an article and loaded a module inside it, so in product details page the customer can click to read a shipping estimation cost.
The link loads a popup window with the article and gets the product weight thus etsimating the cost for dispatch.
For products <=3 kg the cost shows up perfect. For products >3 kg I have problems. Here is the code inside flexi custom code module.
Code: [Select]
<?php
$ZoneCost 3;
$CostPerKilo 1;

if ($product_weight <= 3) {
$rate number_format($ZoneCost,2);
echo 
$rate" €";
echo 
" excluding VAT.";
}
elseif ($product_weight 4){
$rate number_format($ZoneCost+($product_weight 3)*$CostPerKilo,2);
echo 
$rate" €";
echo 
" excluding VAT.";
}
?>

Can someone help pls?
Title: Re: Product shipping cost estimation
Post by: GJC Web Design on May 11, 2016, 17:02:42 pm
surely elseif ($product_weight > 4){

should be  elseif ($product_weight > 3){

or better just }else{ ......
Title: Re: Product shipping cost estimation
Post by: MTechMgr on May 11, 2016, 18:56:19 pm
i made the change
Code: [Select]
<?php
$ZoneCost 3;
$CostPerKilo 1;

if ($product_weight <= 3) {
$rate number_format($ZoneCost,2);
echo 
$rate" €";
echo 
" ex VAT.";
}
elseif ($product_weight 3){
$rate number_format($ZoneCost+($product_weight 3)*$CostPerKilo,2);
echo 
$rate" €";
echo 
" ex VAT.";
}
?>

http://www.messiniantech.eu/online-store/el/products?page=shop.product_details&category_id=120&flypage=flypage.tpl&product_id=731
here is a link to a product with weight 5 kg. I still get 3 €
Title: Re: Product shipping cost estimation
Post by: GJC Web Design on May 11, 2016, 18:59:18 pm
have u checked what $product_weight really is?

a string, an integer etc etc ..  type it to an integer ?
Title: Re: Product shipping cost estimation
Post by: MTechMgr on May 11, 2016, 19:04:02 pm
well... where can I check it?
in backend i put kgs? for weight with the value 5.00 kg
Title: Re: Product shipping cost estimation
Post by: GJC Web Design on May 11, 2016, 19:19:03 pm
come on.. this is basic php.. hardly what this forum is for

if u could write the above code then surely you can also echo out some values and debug it?
Title: Re: Product shipping cost estimation
Post by: MTechMgr on May 11, 2016, 19:37:00 pm
sorry i got lost searching in ps_shipping_method.php in classes folder

I didn't write the code I just made some changes to it and tested. I don't know php coding. :(
Title: Re: Product shipping cost estimation
Post by: MTechMgr on May 11, 2016, 20:45:01 pm
 ::) i got dizzy seraching for the bug
i have some shipping methods does this count in the whole process?
Title: Re: Product shipping cost estimation
Post by: GJC Web Design on May 11, 2016, 23:07:20 pm
the code above has nothing to do with core VM functions or methods.. it is just a simple php calc

and unless you know that $product_weight is actually the actual "product weight" as an integer then it will just return 3 always
Title: Re: Product shipping cost estimation
Post by: MTechMgr on May 11, 2016, 23:26:55 pm
the code above has nothing to do with core VM functions or methods.. it is just a simple php calc

and unless you know that $product_weight is actually the actual "product weight" as an integer then it will just return 3 always

It's a decimal (10,2) in table vm_product
Title: Re: Product shipping cost estimation
Post by: MTechMgr on May 12, 2016, 00:55:09 am
Code: [Select]
<?php
settype
($product_weight"integer");
$ZoneCost 3;
$CostPerKilo 1;

if ($product_weight <= 3) {
$rate number_format($ZoneCost,2);
echo 
$rate" €";
echo 
" πλέον ΦΠΑ.";
}
elseif ($product_weight 3){

$rate $product_weight;
echo 
$rate" €";
echo 
" πλέον ΦΠΑ.";
}
?>

is this correct?
Title: Re: Product shipping cost estimation
Post by: MTechMgr on May 12, 2016, 14:43:09 pm
What can I do now?
I strongly need this solution  :'(
Title: Re: Product shipping cost estimation
Post by: GJC Web Design on May 12, 2016, 23:42:38 pm
employ a coder...   you can't expect free coding solutions from a forum esp. as this has nothing to do with VM..
Title: Re: Product shipping cost estimation
Post by: MTechMgr on May 13, 2016, 13:35:54 pm
I don't expect sth from the forum. Thx for the advice in the problem