Hi, I need custom Opencart 1.5.4 code. Now it is sum of weight of all products in cart but I need use only product with highest weight in cart. Can you help me where custom this? Thank you
In cart is is product with 1 lb, 5 lb, 10 lb which is total 16 lb but I need display and in shipping modules use only highest weight which is 10 lb.
Code: Select all
$max_weight = 0; $id_max = 0;
foreach ($this->cart->getProducts() as $product) {
if ($product['weight']> $max_weight) { $max_weight = $product['weight']; $id_max= $product['product_id'];}
I have not original file from oc154
1. /catalog/controller/checkout/cart.php
search next code
if ($this->cart->hasProducts()
than
$points_total = 0;
foreach ($this->cart->getProducts() as $product) {
if ($product['points']) {
$points_total += $product['points'];
}
}
change
After this cycle will be variable $id_max item ID_PRODUCT with maximum value, $max_weight - max weight
and 0 if not wieght.
2.
catalog/controller/module/cart.php
search
and insert into
1. /catalog/controller/checkout/cart.php
search next code
if ($this->cart->hasProducts()
than
$points_total = 0;
foreach ($this->cart->getProducts() as $product) {
if ($product['points']) {
$points_total += $product['points'];
}
}
change
Code: Select all
//add
$max_weight = 0; $id_max = 0;
//add
foreach ($this->cart->getProducts() as $product) {
//add
if ($product['weight']> $max_weight) { $max_weight = $product['weight']; $id_max= $product['product_id'];}
//add
if ($product['points']) {
$points_total += $product['points'];
}
}
After this cycle will be variable $id_max item ID_PRODUCT with maximum value, $max_weight - max weight
and 0 if not wieght.
2.
catalog/controller/module/cart.php
search
Code: Select all
$this->data['products'] = array();
foreach ($this->cart->getProducts() as $product) {
Code: Select all
$max_weight = 0; $id_max = 0;
foreach ($this->cart->getProducts() as $product) {
if ($product['weight']> $max_weight) { $max_weight = $product['weight']; $id_max= $product['product_id'];}
Who is online
Users browsing this forum: Baidu [Spider] and 16 guests