Commit b9437bf7 authored by Shudrum's avatar Shudrum

Merge branch '1.6' of https://github.com/PrestaShop/PrestaShop into 1.6

parents 7be2f289 feda99fe
......@@ -234,7 +234,8 @@ class CarrierCore extends ObjectModel
*/
public function getDeliveryPriceByWeight($total_weight, $id_zone)
{
$cache_key = $this->id.'_'.$total_weight.'_'.$id_zone;
$id_carrier = (int)$this->id;
$cache_key = $id_carrier.'_'.$total_weight.'_'.$id_zone;
if (!isset(self::$price_by_weight[$cache_key]))
{
$sql = 'SELECT d.`price`
......@@ -243,7 +244,7 @@ class CarrierCore extends ObjectModel
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.'
AND d.`id_carrier` = '.$id_carrier.'
'.Carrier::sqlDeliveryRangeShop('range_weight').'
ORDER BY w.`delimiter1` ASC';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
......@@ -252,11 +253,17 @@ class CarrierCore extends ObjectModel
else
self::$price_by_weight[$cache_key] = $result['price'];
}
$price_by_weight = Hook::exec('actionDeliveryPriceByWeight', array('id_carrier' => $id_carrier, 'total_weight' => $total_weight, 'id_zone' => $id_zone));
if (is_numeric($price_by_weight))
self::$price_by_weight[$cache_key] = $price_by_weight;
return self::$price_by_weight[$cache_key];
}
public static function checkDeliveryPriceByWeight($id_carrier, $total_weight, $id_zone)
{
$id_carrier = (int)$id_carrier;
$cache_key = $id_carrier.'_'.$total_weight.'_'.$id_zone;
if (!isset(self::$price_by_weight2[$cache_key]))
{
......@@ -266,12 +273,17 @@ class CarrierCore extends ObjectModel
WHERE d.`id_zone` = '.(int)$id_zone.'
AND '.(float)$total_weight.' >= w.`delimiter1`
AND '.(float)$total_weight.' < w.`delimiter2`
AND d.`id_carrier` = '.(int)$id_carrier.'
AND d.`id_carrier` = '.$id_carrier.'
'.Carrier::sqlDeliveryRangeShop('range_weight').'
ORDER BY w.`delimiter1` ASC';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
self::$price_by_weight2[$cache_key] = (isset($result['price']));
}
$price_by_weight = Hook::exec('actionDeliveryPriceByWeight', array('id_carrier' => $id_carrier, 'total_weight' => $total_weight, 'id_zone' => $id_zone));
if (is_numeric($price_by_weight))
self::$price_by_weight2[$cache_key] = $price_by_weight;
return self::$price_by_weight2[$cache_key];
}
......@@ -302,6 +314,7 @@ class CarrierCore extends ObjectModel
*/
public function getDeliveryPriceByPrice($order_total, $id_zone, $id_currency = null)
{
$id_carrier = (int)$this->id;
$cache_key = $this->id.'_'.$order_total.'_'.$id_zone.'_'.$id_currency;
if (!isset(self::$price_by_price[$cache_key]))
{
......@@ -314,7 +327,7 @@ class CarrierCore extends ObjectModel
WHERE d.`id_zone` = '.(int)$id_zone.'
AND '.(float)$order_total.' >= r.`delimiter1`
AND '.(float)$order_total.' < r.`delimiter2`
AND d.`id_carrier` = '.(int)$this->id.'
AND d.`id_carrier` = '.$id_carrier.'
'.Carrier::sqlDeliveryRangeShop('range_price').'
ORDER BY r.`delimiter1` ASC';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
......@@ -323,6 +336,11 @@ class CarrierCore extends ObjectModel
else
self::$price_by_price[$cache_key] = $result['price'];
}
$price_by_price = Hook::exec('actionDeliveryPriceByPrice', array('id_carrier' => $id_carrier, 'order_total' => $order_total, 'id_zone' => $id_zone));
if (is_numeric($price_by_price))
self::$price_by_price[$cache_key] = $price_by_price;
return self::$price_by_price[$cache_key];
}
......@@ -337,6 +355,7 @@ class CarrierCore extends ObjectModel
*/
public static function checkDeliveryPriceByPrice($id_carrier, $order_total, $id_zone, $id_currency = null)
{
$id_carrier = (int)$id_carrier;
$cache_key = $id_carrier.'_'.$order_total.'_'.$id_zone.'_'.$id_currency;
if (!isset(self::$price_by_price2[$cache_key]))
{
......@@ -349,12 +368,17 @@ class CarrierCore extends ObjectModel
WHERE d.`id_zone` = '.(int)$id_zone.'
AND '.(float)$order_total.' >= r.`delimiter1`
AND '.(float)$order_total.' < r.`delimiter2`
AND d.`id_carrier` = '.(int)$id_carrier.'
AND d.`id_carrier` = '.$id_carrier.'
'.Carrier::sqlDeliveryRangeShop('range_price').'
ORDER BY r.`delimiter1` ASC';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
self::$price_by_price2[$cache_key] = (isset($result['price']));
}
$price_by_price = Hook::exec('actionDeliveryPriceByPrice', array('id_carrier' => $id_carrier, 'order_total' => $order_total, 'id_zone' => $id_zone));
if (is_numeric($price_by_price))
self::$price_by_price2[$cache_key] = $price_by_price;
return self::$price_by_price2[$cache_key];
}
......
......@@ -3038,7 +3038,7 @@ class CartCore extends ObjectModel
if ($cart_rule['value_real'] == 0)
unset($cart_rules[$key]);
return array(
$summary = array(
'delivery' => $delivery,
'delivery_state' => State::getNameById($delivery->id_state),
'invoice' => $invoice,
......@@ -3063,6 +3063,12 @@ class CartCore extends ObjectModel
'free_ship' => $total_shipping ? 0 : 1,
'carrier' => new Carrier($this->id_carrier, $id_lang),
);
$hook = Hook::exec('actionCartSummary', $summary, null, true);
if (is_array($hook))
$summary = array_merge($summary, array_shift($hook));
return $summary;
}
public function checkQuantities($return_product = false)
......
......@@ -1272,7 +1272,7 @@ class AdminControllerCore extends Controller
$this->errors[] = Tools::displayError('Can not add configuration '.$key.' for lang '.Language::getIsoById((int)$language['id_lang']));
}
}
Configuration::updateValue($key, $list, isset($values['validation']) && $options['validation'] == 'isCleanHtml' ? true : false);
Configuration::updateValue($key, $list, isset($values['validation']) && isset($options['validation']) && $options['validation'] == 'isCleanHtml' ? true : false);
}
else
{
......
......@@ -163,7 +163,7 @@ class DbQueryCore
}
/**
* Add an ORDER B restriction
* Add an ORDER BY restriction
*
* @param string $fields List of fields to sort. E.g. $this->order('myField, b.mySecondField DESC')
* @return DbQuery
......@@ -179,7 +179,7 @@ class DbQueryCore
/**
* Add a GROUP BY restriction
*
* @param string $fields List of fields to sort. E.g. $this->group('myField, b.mySecondField DESC')
* @param string $fields List of fields to group. E.g. $this->group('myField1, myField2')
* @return DbQuery
*/
public function groupBy($fields)
......@@ -193,7 +193,7 @@ class DbQueryCore
/**
* Limit results in query
*
* @param string $fields List of fields to sort. E.g. $this->order('myField, b.mySecondField DESC')
* @param string $fields Couple of values to set limit and offset. E.g. $this->limit(1, 10)
* @return DbQuery
*/
public function limit($limit, $offset = 0)
......@@ -210,7 +210,7 @@ class DbQueryCore
}
/**
* Generate and get the query
* Generate and get the query as a string
*
* @return string
*/
......
......@@ -1912,8 +1912,8 @@ class OrderCore extends ObjectModel
if ($res = (int)Db::getInstance()->getvalue('
SELECT `id_order_invoice`
FROM `'._DB_PREFIX_.'order_invoice`
WHERE `id_order` = '.(int)$this->id.'
AND `number` > 0'));
WHERE `id_order` = '.(int)$this->id.
(Configuration::get('PS_INVOICE') ? ' AND `number` > 0' : '')))
return $res;
return false;
}
......
......@@ -418,10 +418,17 @@ class ShopCore extends ObjectModel
if (count($params))
$url .= '?'.http_build_query($params);
}
$redirect_type = Configuration::get('PS_CANONICAL_REDIRECT') == 2 ? '301' : '302';
header('HTTP/1.0 '.$redirect_type.' Moved');
header('location: http://'.$url);
exit;
$redirect_type = Configuration::get('PS_CANONICAL_REDIRECT');
if ($redirect_type != 0)
{
$redirect_code = ($redirect_type == 1 ? '302' : '301');
header('HTTP/1.0 '.$redirect_code.' Moved');
header('location: http://'.$url);
exit;
}
else
$shop = $default_shop;
}
elseif (defined('_PS_ADMIN_DIR_') && empty($shop->physical_uri))
{
......
......@@ -734,7 +734,7 @@ class StockManagerCore implements StockManagerInterface
$stock_quantity += Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT SUM(s.`usable_quantity`) as quantity
FROM '._DB_PREFIX_.'stock s
LEFT JOIN '._DB_PREFIX_.'warehouse_carrier wc ON wc.`id_warehouse` = s.`id_warehouse`
LEFT JOIN ps_carrier c ON wc.`id_carrier` = c.`id_reference`
LEFT JOIN '._DB_PREFIX_.'carrier c ON wc.`id_carrier` = c.`id_reference`
WHERE s.`id_product` = '.(int)$id_product.' AND s.`id_product_attribute` = '.(int)$id_product_attribute.' AND s.`id_warehouse` = '.$result['id_warehouse'].' AND c.`id_carrier` IN ('.rtrim($delivery_option[(int)Context::getContext()->cart->id_address_delivery], ',').') GROUP BY s.`id_product`');
else
$stock_quantity += Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT SUM(s.`usable_quantity`) as quantity
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment