mrhaha 0 Posted October 29, 2009 I just fond Prestashop last week. it is really a good product! Easy to use & Fast!after i uploaded all my products, i only discovered that the shipping charges function only has By Price/ By Weight. What i need is set by Item. each item has it own shipping fee.i tried to google on the internet, i still not able to find the solution.anyone hav this Shipping Fee Per Item?pls help me! my business is hanging now!thanks in advance!!!!! Share this post Link to post Share on other sites
rocky 953 Posted October 30, 2009 The easiest way I know to do this is to enter the per-item shipping cost in the weight field of each product, then modify classes/Carrier.php and change: /** * Get delivery prices for a given order * * @param floatval $totalWeight Order total weight * @param integer $id_zone Zone id (for customer delivery address) * @return float Delivery price */ public function getDeliveryPriceByWeight($totalWeight, $id_zone) { if (isset(self::$priceByWeight[$this->id])) return self::$priceByWeight[$this->id]; $result = Db::getInstance()->getRow(' 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` = '.intval($id_zone).' AND '.floatval($totalWeight).' <= w.`delimiter2` AND d.`id_carrier` = '.intval($this->id).' ORDER BY w.`delimiter1` ASC'); if (!isset($result['price'])) return $this->getMaxDeliveryPriceByWeight($id_zone); return $result['price']; } static public function checkDeliveryPriceByWeight($id_carrier, $totalWeight, $id_zone) { $result = Db::getInstance()->getRow(' 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` = '.intval($id_zone).' AND '.floatval($totalWeight).' <= w.`delimiter2` AND d.`id_carrier` = '.intval($id_carrier).' ORDER BY w.`delimiter1` ASC'); if (!isset($result['price'])) return false; return true; } public function getMaxDeliveryPriceByWeight($id_zone) { $result = Db::getInstance()->ExecuteS(' SELECT d.`price` FROM `'._DB_PREFIX_.'delivery` d INNER JOIN `'._DB_PREFIX_.'range_weight` w ON d.`id_range_weight` = w.`id_range_weight` WHERE d.`id_zone` = '.intval($id_zone).' AND d.`id_carrier` = '.intval($this->id).' ORDER BY w.`delimiter2` DESC LIMIT 1'); if (!isset($result[0]['price'])) return false; return $result[0]['price']; } to: /** * Get delivery prices for a given order * * @param floatval $totalWeight Order total weight * @param integer $id_zone Zone id (for customer delivery address) * @return float Delivery price */ public function getDeliveryPriceByWeight($totalWeight, $id_zone) { /* if (isset(self::$priceByWeight[$this->id])) return self::$priceByWeight[$this->id]; $result = Db::getInstance()->getRow(' 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` = '.intval($id_zone).' AND '.floatval($totalWeight).' <= w.`delimiter2` AND d.`id_carrier` = '.intval($this->id).' ORDER BY w.`delimiter1` ASC'); if (!isset($result['price'])) return $this->getMaxDeliveryPriceByWeight($id_zone); return $result['price']; */ return $totalWeight; } static public function checkDeliveryPriceByWeight($id_carrier, $totalWeight, $id_zone) { /* $result = Db::getInstance()->getRow(' 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` = '.intval($id_zone).' AND '.floatval($totalWeight).' <= w.`delimiter2` AND d.`id_carrier` = '.intval($id_carrier).' ORDER BY w.`delimiter1` ASC'); if (!isset($result['price'])) return false; */ return true; } public function getMaxDeliveryPriceByWeight($id_zone) { /* $result = Db::getInstance()->ExecuteS(' SELECT d.`price` FROM `'._DB_PREFIX_.'delivery` d INNER JOIN `'._DB_PREFIX_.'range_weight` w ON d.`id_range_weight` = w.`id_range_weight` WHERE d.`id_zone` = '.intval($id_zone).' AND d.`id_carrier` = '.intval($this->id).' ORDER BY w.`delimiter2` DESC LIMIT 1'); if (!isset($result[0]['price'])) return false; return $result[0]['price']; */ return 1000000; } This will make the shipping cost the total weight of the cart. Make sure that on the Shipping tab, you have Billing set to "According to total weight". You can also go to Tools > Translations, select Back Office Translations, click a Flag, then change every instance of "Weight" to "Shipping cost" to make it more obvious in the Back Office that weight is now shipping cost.Note that this will cause all carriers to have the same shipping prices. If you will need different carriers to have different per-item shipping costs, it won't work. I'll add a Shipping module to my list of modules to do in the future. 1 Share this post Link to post Share on other sites
mrhaha 0 Posted October 30, 2009 hi rocky,thanks for your post! Share this post Link to post Share on other sites
allan1412 0 Posted March 29, 2010 Hi RockyThanks for this.Is there any way to include a 'Pick Up At Store' option on the 'Shipping' step page which would remove the 'per item shipping charge'? Share this post Link to post Share on other sites
rocky 953 Posted March 29, 2010 I don't think you can do that, since the getDeliveryPriceByWeight function doesn't include an $id_carrier parameter. Share this post Link to post Share on other sites
curye 0 Posted April 3, 2010 You can give each of your items same weight and charge shipping by weight in increments in admin panel. Share this post Link to post Share on other sites
poplol 3 Posted April 13, 2010 Hi RockyI need the Weight Property for something else when exporting the Invoices.Is there a way to get the value from another texbox from the product page. For Example lets say LOCATION ? Share this post Link to post Share on other sites
andybr1ggs 3 Posted May 30, 2010 hi thanks for this, what is the line it starts on in carrier.php, ive tried looking but theres lines in there that look the same to me, also what line will it round about finish.....just so i dont mess anything upThanksAndy. Share this post Link to post Share on other sites
andybr1ggs 3 Posted May 30, 2010 Thank you rocky...managed it, youve made it alot easier for me :-) Share this post Link to post Share on other sites
roflmyeggo 19 Posted December 12, 2013 Hey rocky, Would this work for Prestashop 1.5.x? Thanks, eggo Share this post Link to post Share on other sites