Hello,
I am looking for someone who can help me with the total weight of the products.
I want these total weight showing up on the E-mail confirmation.
Because when we have an order we want to directly see the weight.
Is this possible? Which file I need to edit?
Can someone help me with this? I think that eventually a lot of people wants this function.
Thanks in advance
gr Luuk
I did some research.
I found/knew that <?php echo $product->product_weight ?> is used to show the weight of the product.
But how can I fix this that it contains the total width? Is this possible?
I want to attach this rule in the e-mail that the owner receives. Also I want that the weight is not visible in the customers email. Which file/part do I need to edit then?
Thanks in advance
Hi
to display the weight you can use this code in confirmation email:
foreach ( $this->orderDetails['items'] as $items ) {
$q = 'SELECT `product_weight` FROM `#__virtuemart_products` WHERE `virtuemart_product_id`=' . $items->virtuemart_product_id;
$db = JFactory::getDbo();
$db->setQuery($q);
$productWeight = $db->loadResult();
$totalWeight += $productWeight;
}
echo $totalWeight;
To display it only in the vendor email, put it for example in mail_html_vendor.php.
Regards,
Maik
Hi,
Thanks for your reply.
I added the code to mail_html_vendor.php and now it shows the weight. Thanks!
But unfortunately the weight doesn't get counted when I have a different quantity per product. I only see the weight of the products that are selected. So the first product is 2 kg and the other is 1 kg. Together these are 3 kg. So it shows 3 kg. But when I order 3 times product 1 and 2 times product 2 these weights doesn't get counted.
So the code doesn't make use of the quantity.
OK, there is one thing missing.
Please try this:
$totalWeight = 0;
foreach ( $this->orderDetails['items'] as $items ) {
$q = 'SELECT `product_weight` FROM `#__virtuemart_products` WHERE `virtuemart_product_id`=' . $items->virtuemart_product_id;
$db = JFactory::getDbo();
$db->setQuery($q);
$productWeight = $db->loadResult();
$totalWeight += $productWeight * $items->product_quantity;
}
echo $totalWeight;
Regards,
Maik
Quote from: kkmediaproduction on January 28, 2013, 13:04:27 PM
OK, there is one thing missing.
Please try this:
$totalWeight = 0;
foreach ( $this->orderDetails['items'] as $items ) {
$q = 'SELECT `product_weight` FROM `#__virtuemart_products` WHERE `virtuemart_product_id`=' . $items->virtuemart_product_id;
$db = JFactory::getDbo();
$db->setQuery($q);
$productWeight = $db->loadResult();
$totalWeight += $productWeight * $items->product_quantity;
}
echo $totalWeight;
Regards,
Maik
Great great great! Now it's working!
I think many people will use this function :)
Thank you very much!
8)
really no need to query the DB like that product weight is already in the array
$totalWeight = 0;
foreach ( $this->orderDetails['items'] as $items ) {
$db = JFactory::getDbo();
$db->setQuery($q);
$productWeight = $db->loadResult();
$totalWeight += $productWeight * $items->product_quantity;
}
echo $totalWeight;
Is this the code that I should insert into the page? I delete the query code.
No, the weight is not in the items array. You must use my code with query.
Please paste the code in this category for next VM verion: http://forum.virtuemart.net/index.php?board=139.0