Jump to content

Price per weight on carrier


Recommended Posts

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 by Bicss (see edit history)
Link to comment
Share on other sites

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 by Bicss (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...