Jump to content

How to get values of shipping prices to JS array


Amazzing
 Share

Recommended Posts

Hello dear community,

 

I have set up 3 carriers for my store and 3 zones.

There are 70 weight ranges (1,2,3,4,5...70)

And there is a certain price value specified for each weight range for each zone. 

 

Now am working on an addon, based on JavaScript.

 

And I need to get these price values for each weight range for eachzone.

I will create arrays, like:

var zone1carr1 = [price111,price112,price113, etc];
var zone1carr2 = [price121,price122,price123, etc];

So, my question is, how to get these price values to JS?

 

PS ver 1.5.4.1

Edited by Amazzing (see edit history)

Share this post


Link to post
Share on other sites

In Carrier.php there's the following function:

 
	/**
	 * Get delivery prices for a given shipping method (price/weight)
	 *
	 * @param string $rangeTable Table name (price or weight)
	 * @return array Delivery prices
	 */
	public static function getDeliveryPriceByRanges($range_table, $id_carrier)
	{
		$sql = 'SELECT d.`id_'.bqSQL($range_table).'`, d.id_carrier, d.id_zone, d.price
				FROM '._DB_PREFIX_.'delivery d
				LEFT JOIN `'._DB_PREFIX_.bqSQL($range_table).'` r ON r.`id_'.bqSQL($range_table).'` = d.`id_'.bqSQL($range_table).'`
				WHERE d.id_carrier = '.(int)$id_carrier.'
					AND d.`id_'.bqSQL($range_table).'` IS NOT NULL
					AND d.`id_'.bqSQL($range_table).'` != 0
					'.Carrier::sqlDeliveryRangeShop($range_table).'
				ORDER BY r.delimiter1';
		return Db::getInstance()->executeS($sql);
	}

(code from 1.5.5.0)
 
So then you can run this for each carrier and then you only have to go through it and take out the desired price and separate for each zone available.
 
N.B. the type of $range_table ('range_price' or 'range_weight') you can find by asking the $carrier: 
$range_table = $carrier->getRangeTable();
 

My 2 cents,

pascal.

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More