Bicss Posted July 29, 2015 Share Posted July 29, 2015 (edited) Hi, If i want to configure on the carrier if the product by weight has a price how can i make it? The ranges are 0kg-1kg = 1$ 1kg-2kg = 2$ For example, if the weight is 1kg = 1$ If the weight is 2kg = 2$ BUT, this is the inportant thing. If the weight is 1,5kg = 1.5$ The formula will be weight of the product x the shipping cost Thanks! Edited July 29, 2015 by Bicss (see edit history) Link to comment Share on other sites More sharing options...
Paulito Posted July 29, 2015 Share Posted July 29, 2015 Hello Well, the obvious solution would be: 1.1kg - 1.99kg = 1.5$ But I am sure I must be not understanding your question Paul Link to comment Share on other sites More sharing options...
Bicss Posted July 29, 2015 Author Share Posted July 29, 2015 (edited) Hi Paulito, My question is that set all ranges is a suicide. Because If the shipping cost per kg is 1$ = 1kg 1.1kg will be 1,1$ 1.2kg will be 1,2$ 1.3kg - 1.3$ 1.253,22kg - 1.25,322$ etc etc And setup all the ranges to for example 1000kg is a suicide. The easiest formula will be setup a carrier saying, 1kg = 1$ and it has to calculate all the ranges. Product weight x 1kg = shipping cost Thanks Edited July 29, 2015 by Bicss (see edit history) Link to comment Share on other sites More sharing options...
cooliyev Posted August 6, 2015 Share Posted August 6, 2015 same problem. if 0-1kg = 10$ and When i add a product (weight = 0,320 g) to cart shipping cost have to be equal 3,2$, but appears 10$. How fix it? Please help Link to comment Share on other sites More sharing options...
cooliyev Posted August 7, 2015 Share Posted August 7, 2015 Go to classes/Carrier.php , find this module getDeliveryPriceByWeight() and change code to this public function getDeliveryPriceByWeight($total_weight, $id_zone) { $cache_key = $this->id.'_'.$total_weight.'_'.$id_zone; if (!isset(self::$price_by_weight[$cache_key])) { $sql = 'SELECT d.`price` FROM `'._DB_PREFIX_.'delivery` d LEFT JOIN `'._DB_PREFIX_.'range_weight` w ON (d.`id_range_weight` = w.`id_range_weight`) WHERE d.`id_zone` = '.(int)$id_zone.' AND '.(float)$total_weight.' >= w.`delimiter1` AND '.(float)$total_weight.' < w.`delimiter2` AND d.`id_carrier` = '.(int)$this->id.' '.Carrier::sqlDeliveryRangeShop('range_weight').' ORDER BY w.`delimiter1` ASC'; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); if (!isset($result['price'])) self::$price_by_weight[$cache_key] = $this->getMaxDeliveryPriceByWeight($id_zone); else self::$price_by_weight[$cache_key] = $total_weight * $result['price']; } return self::$price_by_weight[$cache_key]; } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now