Author Topic: Product shipping cost estimation  (Read 3105 times)

MTechMgr

  • Beginner
  • *
  • Posts: 19
    • Messinian Tech
  • Skype Name: messinian-tech
  • VirtueMart Version: 1.1.9
Product shipping cost estimation
« 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?

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 7613
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 2.6.22 & 3.2.2
Re: Product shipping cost estimation
« Reply #1 on: May 11, 2016, 17:02:42 pm »
surely elseif ($product_weight > 4){

should be  elseif ($product_weight > 3){

or better just }else{ ......
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

MTechMgr

  • Beginner
  • *
  • Posts: 19
    • Messinian Tech
  • Skype Name: messinian-tech
  • VirtueMart Version: 1.1.9
Re: Product shipping cost estimation
« Reply #2 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 €

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 7613
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 2.6.22 & 3.2.2
Re: Product shipping cost estimation
« Reply #3 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 ?
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

MTechMgr

  • Beginner
  • *
  • Posts: 19
    • Messinian Tech
  • Skype Name: messinian-tech
  • VirtueMart Version: 1.1.9
Re: Product shipping cost estimation
« Reply #4 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

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 7613
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 2.6.22 & 3.2.2
Re: Product shipping cost estimation
« Reply #5 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?
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

MTechMgr

  • Beginner
  • *
  • Posts: 19
    • Messinian Tech
  • Skype Name: messinian-tech
  • VirtueMart Version: 1.1.9
Re: Product shipping cost estimation
« Reply #6 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. :(

MTechMgr

  • Beginner
  • *
  • Posts: 19
    • Messinian Tech
  • Skype Name: messinian-tech
  • VirtueMart Version: 1.1.9
Re: Product shipping cost estimation
« Reply #7 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?

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 7613
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 2.6.22 & 3.2.2
Re: Product shipping cost estimation
« Reply #8 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
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

MTechMgr

  • Beginner
  • *
  • Posts: 19
    • Messinian Tech
  • Skype Name: messinian-tech
  • VirtueMart Version: 1.1.9
Re: Product shipping cost estimation
« Reply #9 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

MTechMgr

  • Beginner
  • *
  • Posts: 19
    • Messinian Tech
  • Skype Name: messinian-tech
  • VirtueMart Version: 1.1.9
Re: Product shipping cost estimation
« Reply #10 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?

MTechMgr

  • Beginner
  • *
  • Posts: 19
    • Messinian Tech
  • Skype Name: messinian-tech
  • VirtueMart Version: 1.1.9
Re: Product shipping cost estimation
« Reply #11 on: May 12, 2016, 14:43:09 pm »
What can I do now?
I strongly need this solution  :'(

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 7613
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 2.6.22 & 3.2.2
Re: Product shipping cost estimation
« Reply #12 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..
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

MTechMgr

  • Beginner
  • *
  • Posts: 19
    • Messinian Tech
  • Skype Name: messinian-tech
  • VirtueMart Version: 1.1.9
Re: Product shipping cost estimation
« Reply #13 on: May 13, 2016, 13:35:54 pm »
I don't expect sth from the forum. Thx for the advice in the problem