[-] BO : error message on install module
This commit is contained in:
+8
-9
@@ -1331,6 +1331,9 @@ class CartCore extends ObjectModel
|
||||
else
|
||||
$shipping_fees = 0;
|
||||
|
||||
if ($type == Cart::ONLY_SHIPPING)
|
||||
return $shipping_fees;
|
||||
|
||||
if ($type == Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING)
|
||||
$type = Cart::ONLY_PRODUCTS;
|
||||
|
||||
@@ -1455,12 +1458,14 @@ class CartCore extends ObjectModel
|
||||
$wrapping_fees = 0;
|
||||
if ($this->gift)
|
||||
$wrapping_fees = Tools::convertPrice(Tools::ps_round($this->getGiftWrappingPrice($with_taxes), 2), Currency::getCurrencyInstance((int)$this->id_currency));
|
||||
if ($type == Cart::ONLY_WRAPPING)
|
||||
return $wrapping_fees;
|
||||
|
||||
$order_total_discount = 0;
|
||||
if (!in_array($type, array(Cart::ONLY_SHIPPING, Cart::ONLY_PRODUCTS)) && CartRule::isFeatureActive())
|
||||
{
|
||||
// First, retrieve the cart rules associated to this "getOrderTotal"
|
||||
if ($with_shipping)
|
||||
if ($with_shipping || $type == Cart::ONLY_DISCOUNTS)
|
||||
$cart_rules = $this->getCartRules(CartRule::FILTER_ACTION_ALL);
|
||||
else
|
||||
{
|
||||
@@ -1486,7 +1491,7 @@ class CartCore extends ObjectModel
|
||||
foreach ($cart_rules as $cart_rule)
|
||||
{
|
||||
// If the cart rule offers free shipping, add the shipping cost
|
||||
if ($with_shipping && $cart_rule['obj']->free_shipping)
|
||||
if (($with_shipping || $type == Cart::ONLY_DISCOUNTS) && $cart_rule['obj']->free_shipping)
|
||||
$order_total_discount += Tools::ps_round($cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_SHIPPING, ($param_product ? $package : null), $use_cache), 2);
|
||||
|
||||
// If the cart rule is a free gift, then add the free gift value only if the gift is in this package
|
||||
@@ -1512,12 +1517,6 @@ class CartCore extends ObjectModel
|
||||
$order_total -= $order_total_discount;
|
||||
}
|
||||
|
||||
if ($type == Cart::ONLY_SHIPPING)
|
||||
return $shipping_fees;
|
||||
|
||||
if ($type == Cart::ONLY_WRAPPING)
|
||||
return $wrapping_fees;
|
||||
|
||||
if ($type == Cart::BOTH)
|
||||
$order_total += $shipping_fees + $wrapping_fees;
|
||||
|
||||
@@ -2837,8 +2836,8 @@ class CartCore extends ObjectModel
|
||||
$invoice = new Address((int)$this->id_address_invoice);
|
||||
|
||||
// New layout system with personalization fields
|
||||
$formatted_addresses['delivery'] = AddressFormat::getFormattedLayoutData($delivery);
|
||||
$formatted_addresses['invoice'] = AddressFormat::getFormattedLayoutData($invoice);
|
||||
$formatted_addresses['delivery'] = AddressFormat::getFormattedLayoutData($delivery);
|
||||
|
||||
$total_tax = $this->getOrderTotal() - $this->getOrderTotal(false);
|
||||
|
||||
|
||||
+37
-20
@@ -31,6 +31,7 @@ class CartRuleCore extends ObjectModel
|
||||
const FILTER_ACTION_SHIPPING = 2;
|
||||
const FILTER_ACTION_REDUCTION = 3;
|
||||
const FILTER_ACTION_GIFT = 4;
|
||||
const FILTER_ACTION_ALL_NOCAP = 5;
|
||||
|
||||
const BO_ORDER_CODE_PREFIX = 'BO_ORDER_';
|
||||
|
||||
@@ -119,14 +120,20 @@ class CartRuleCore extends ObjectModel
|
||||
/**
|
||||
* @see ObjectModel::add()
|
||||
*/
|
||||
public function add($autodate = true, $nullValues = false)
|
||||
public function add($autodate = true, $null_values = false)
|
||||
{
|
||||
if (!parent::add($autodate, $nullValues))
|
||||
if (!parent::add($autodate, $null_values))
|
||||
return false;
|
||||
|
||||
Configuration::updateGlobalValue('PS_CART_RULE_FEATURE_ACTIVE', '1');
|
||||
return true;
|
||||
}
|
||||
|
||||
public function update($null_values = false)
|
||||
{
|
||||
Cache::clean('getContextualValue_'.$this->id.'_*');
|
||||
return parent::update($null_values);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ObjectModel::delete()
|
||||
@@ -216,27 +223,26 @@ class CartRuleCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'cart_rule` cr
|
||||
LEFT JOIN `'._DB_PREFIX_.'cart_rule_lang` crl ON (cr.`id_cart_rule` = crl.`id_cart_rule` AND crl.`id_lang` = '.(int)$id_lang.')
|
||||
WHERE (
|
||||
cr.`id_customer` = '.(int)$id_customer.'
|
||||
cr.`id_customer` = '.(int)$id_customer.' OR cr.group_restriction = 1
|
||||
'.($includeGeneric ? 'OR cr.`id_customer` = 0' : '').'
|
||||
)
|
||||
AND cr.date_from < "'.date('Y-m-d H:i:s').'"
|
||||
AND cr.date_to > "'.date('Y-m-d H:i:s').'"
|
||||
'.($active ? 'AND cr.`active` = 1' : '').'
|
||||
'.($inStock ? 'AND cr.`quantity` > 0' : ''));
|
||||
|
||||
// Remove cart rule that does not match the customer groups
|
||||
if ($includeGeneric)
|
||||
{
|
||||
$customerGroups = Customer::getGroupsStatic($id_customer);
|
||||
foreach ($result as $key => $cart_rule)
|
||||
if ($cart_rule['group_restriction'])
|
||||
{
|
||||
$cartRuleGroups = Db::getInstance()->getValue('SELECT id_group FROM '._DB_PREFIX_.'cart_rule_group WHERE id_cart_rule = '.(int)$cart_rule['id_cart_rule']);
|
||||
foreach ($cartRuleGroups as $cartRuleGroup)
|
||||
if (in_array($cartRuleGroups['id_group'], $customerGroups))
|
||||
continue 2;
|
||||
$customerGroups = Customer::getGroupsStatic($id_customer);
|
||||
foreach ($result as $key => $cart_rule)
|
||||
if ($cart_rule['group_restriction'])
|
||||
{
|
||||
$cartRuleGroups = Db::getInstance()->executeS('SELECT id_group FROM '._DB_PREFIX_.'cart_rule_group WHERE id_cart_rule = '.(int)$cart_rule['id_cart_rule']);
|
||||
foreach ($cartRuleGroups as $cartRuleGroup)
|
||||
if (in_array($cartRuleGroup['id_group'], $customerGroups))
|
||||
continue 2;
|
||||
|
||||
unset($result[$key]);
|
||||
}
|
||||
}
|
||||
unset($result[$key]);
|
||||
}
|
||||
|
||||
foreach ($result as &$cart_rule)
|
||||
if ($cart_rule['quantity_per_user'])
|
||||
@@ -749,7 +755,7 @@ class CartRuleCore extends ObjectModel
|
||||
return Cache::retrieve($cache_id);
|
||||
|
||||
// Free shipping on selected carriers
|
||||
if ($this->free_shipping && ($filter == CartRule::FILTER_ACTION_ALL || $filter == CartRule::FILTER_ACTION_SHIPPING))
|
||||
if ($this->free_shipping && in_array($filter, array(CartRule::FILTER_ACTION_ALL, CartRule::FILTER_ACTION_ALL_NOCAP, CartRule::FILTER_ACTION_SHIPPING)))
|
||||
{
|
||||
if (!$this->carrier_restriction)
|
||||
$reduction_value += $context->cart->getOrderTotal($use_tax, Cart::ONLY_SHIPPING, is_null($package) ? null : $package['products'], is_null($package) ? null : $package['id_carrier']);
|
||||
@@ -767,7 +773,7 @@ class CartRuleCore extends ObjectModel
|
||||
}
|
||||
}
|
||||
|
||||
if ($filter == CartRule::FILTER_ACTION_ALL || $filter == CartRule::FILTER_ACTION_REDUCTION)
|
||||
if (in_array($filter, array(CartRule::FILTER_ACTION_ALL, CartRule::FILTER_ACTION_ALL_NOCAP, CartRule::FILTER_ACTION_REDUCTION)))
|
||||
{
|
||||
// Discount (%) on the whole order
|
||||
if ($this->reduction_percent && $this->reduction_product == 0)
|
||||
@@ -858,7 +864,15 @@ class CartRuleCore extends ObjectModel
|
||||
|
||||
// If it has the same tax application that you need, then it's the right value, whatever the product!
|
||||
if ($this->reduction_tax == $use_tax)
|
||||
{
|
||||
// The reduction cannot exceed the products total, except when we do not want it to be limited (for the partial use calculation)
|
||||
if ($filter != CartRule::FILTER_ACTION_ALL_NOCAP)
|
||||
{
|
||||
$cart_amount = $context->cart->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS);
|
||||
$reduction_amount = min($reduction_amount, $cart_amount);
|
||||
}
|
||||
$reduction_value += $prorata * $reduction_amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->reduction_product > 0)
|
||||
@@ -884,9 +898,12 @@ class CartRuleCore extends ObjectModel
|
||||
// Discount (¤) on the whole order
|
||||
elseif ($this->reduction_product == 0)
|
||||
{
|
||||
// TODO : this should not use the prorata
|
||||
$cart_amount_ti = $context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS);
|
||||
$cart_amount_te = $context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
|
||||
|
||||
// The reduction cannot exceed the products total, except when we do not want it to be limited (for the partial use calculation)
|
||||
if ($filter != CartRule::FILTER_ACTION_ALL_NOCAP)
|
||||
$reduction_amount = min($reduction_amount, $this->reduction_tax ? $cart_amount_ti : $cart_amount_te);
|
||||
|
||||
$cart_vat_amount = $cart_amount_ti - $cart_amount_te;
|
||||
|
||||
@@ -911,7 +928,7 @@ class CartRuleCore extends ObjectModel
|
||||
}
|
||||
|
||||
// Free gift
|
||||
if ((int)$this->gift_product && ($filter == CartRule::FILTER_ACTION_ALL || $filter == CartRule::FILTER_ACTION_GIFT))
|
||||
if ((int)$this->gift_product && in_array($filter, array(CartRule::FILTER_ACTION_ALL, CartRule::FILTER_ACTION_ALL_NOCAP, CartRule::FILTER_ACTION_GIFT)))
|
||||
{
|
||||
$id_address = (is_null($package) ? 0 : $package['id_address']);
|
||||
foreach ($package_products as $product)
|
||||
|
||||
@@ -412,16 +412,17 @@ class CustomerCore extends ObjectModel
|
||||
*/
|
||||
public static function customerHasAddress($id_customer, $id_address)
|
||||
{
|
||||
if (!array_key_exists($id_customer, self::$_customerHasAddress))
|
||||
$key = (int)$id_customer.'-'.(int)$id_address;
|
||||
if (!array_key_exists($id_address, self::$_customerHasAddress))
|
||||
{
|
||||
self::$_customerHasAddress[$id_customer] = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
self::$_customerHasAddress[$key] = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT `id_address`
|
||||
FROM `'._DB_PREFIX_.'address`
|
||||
WHERE `id_customer` = '.(int)$id_customer.'
|
||||
AND `id_address` = '.(int)$id_address.'
|
||||
AND `deleted` = 0');
|
||||
}
|
||||
return self::$_customerHasAddress[$id_customer];
|
||||
return self::$_customerHasAddress[$key];
|
||||
}
|
||||
|
||||
public static function resetAddressCache($id_customer)
|
||||
@@ -438,13 +439,14 @@ class CustomerCore extends ObjectModel
|
||||
*/
|
||||
public function getAddresses($id_lang)
|
||||
{
|
||||
$sql = 'SELECT a.*, cl.`name` AS country, s.name AS state, s.iso_code AS state_iso
|
||||
$sql = 'SELECT DISTINCT a.*, cl.`name` AS country, s.name AS state, s.iso_code AS state_iso
|
||||
FROM `'._DB_PREFIX_.'address` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'country` c ON (a.`id_country` = c.`id_country`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'state` s ON (s.`id_state` = a.`id_state`)
|
||||
'.(Context::getContext()->shop->getGroup()->share_order ? '' : Shop::addSqlAssociation('country', 'c')).'
|
||||
WHERE `id_lang` = '.(int)$id_lang.' AND `id_customer` = '.(int)$this->id.' AND a.`deleted` = 0';
|
||||
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
}
|
||||
|
||||
|
||||
@@ -468,7 +468,7 @@ class DispatcherCore
|
||||
if ($keywords)
|
||||
{
|
||||
$transform_keywords = array();
|
||||
preg_match_all('#\\\{(([^{}]+)\\\:)?('.implode('|', array_keys($keywords)).')(\\\:([^{}]+))?\\\}#', $regexp, $m);
|
||||
preg_match_all('#\\\{(([^{}]*)\\\:)?('.implode('|', array_keys($keywords)).')(\\\:([^{}]*))?\\\}#', $regexp, $m);
|
||||
for ($i = 0, $total = count($m[0]); $i < $total; $i++)
|
||||
{
|
||||
$prepend = $m[2][$i];
|
||||
@@ -537,7 +537,7 @@ class DispatcherCore
|
||||
if (!isset($this->routes[$id_lang]) && !isset($this->routes[$id_lang][$route_id]))
|
||||
return false;
|
||||
|
||||
return preg_match('#\{([^{}]+:)?'.preg_quote($keyword, '#').'(:[^{}])?\}#', $this->routes[$id_lang][$route_id]['rule']);
|
||||
return preg_match('#\{([^{}]*:)?'.preg_quote($keyword, '#').'(:[^{}]*)?\}#', $this->routes[$id_lang][$route_id]['rule']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -554,7 +554,7 @@ class DispatcherCore
|
||||
return false;
|
||||
|
||||
foreach ($this->default_routes[$route_id]['keywords'] as $keyword => $data)
|
||||
if (isset($data['param']) && !preg_match('#\{([^{}]+:)?'.$keyword.'(:[^{}])?\}#', $rule))
|
||||
if (isset($data['param']) && !preg_match('#\{([^{}]*:)?'.$keyword.'(:[^{}]*)?\}#', $rule))
|
||||
$errors[] = $keyword;
|
||||
|
||||
return (count($errors)) ? false : true;
|
||||
@@ -614,10 +614,10 @@ class DispatcherCore
|
||||
$replace = $route['keywords'][$key]['prepend'].$params[$key].$route['keywords'][$key]['append'];
|
||||
else
|
||||
$replace = '';
|
||||
$url = preg_replace('#\{([^{}]+:)?'.$key.'(:[^{}])?\}#', $replace, $url);
|
||||
$url = preg_replace('#\{([^{}]*:)?'.$key.'(:[^{}]*)?\}#', $replace, $url);
|
||||
}
|
||||
}
|
||||
$url = preg_replace('#\{([^{}]+:)?[a-z0-9_]+?(:[^{}])?\}#', '', $url);
|
||||
$url = preg_replace('#\{([^{}]*:)?[a-z0-9_]+?(:[^{}]*)?\}#', '', $url);
|
||||
if (count($add_param))
|
||||
$url .= '?'.http_build_query($add_param, '', '&');
|
||||
}
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ class HookCore extends ObjectModel
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT * FROM `'._DB_PREFIX_.'hook` h
|
||||
'.($position ? 'WHERE h.`position` = 1' : '').'
|
||||
ORDER BY `title`'
|
||||
ORDER BY `name`'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,10 @@ class ImageManagerCore
|
||||
*/
|
||||
public static function resize($src_file, $dst_file, $dst_width = null, $dst_height = null, $file_type = 'jpg', $force_type = false)
|
||||
{
|
||||
clearstatcache(true, $src_file);
|
||||
if (PHP_VERSION_ID < 50300)
|
||||
clearstatcache();
|
||||
else
|
||||
clearstatcache(true, $src_file);
|
||||
|
||||
if (!file_exists($src_file) || !filesize($src_file))
|
||||
return false;
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ class MediaCore
|
||||
'ui.mouse' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => false),
|
||||
'ui.position' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array(), 'theme' => false),
|
||||
'ui.draggable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => false),
|
||||
'ui.droppable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('uicore', 'ui.widget', 'ui.mouse', 'ui.draggable'), 'theme' => false),
|
||||
'ui.droppable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse', 'ui.draggable'), 'theme' => false),
|
||||
'ui.resizable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
|
||||
'ui.selectable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
|
||||
'ui.sortable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
|
||||
@@ -539,4 +539,4 @@ class MediaCore
|
||||
return array_merge(array($protocol_link.Tools::getMediaServer($url).$url), $js_external_files);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,8 +406,8 @@ abstract class PaymentModuleCore extends Module
|
||||
{
|
||||
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
|
||||
$values = array(
|
||||
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL, $package),
|
||||
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL, $package)
|
||||
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
|
||||
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
|
||||
);
|
||||
|
||||
// If the reduction is not applicable to this order, then continue with the next one
|
||||
@@ -469,7 +469,7 @@ abstract class PaymentModuleCore extends Module
|
||||
$values['tax_excl'] -= $values['tax_excl'] - $order->total_products;
|
||||
}
|
||||
|
||||
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values);
|
||||
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
|
||||
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used))
|
||||
{
|
||||
@@ -616,7 +616,7 @@ abstract class PaymentModuleCore extends Module
|
||||
{
|
||||
$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $this->context->smarty);
|
||||
$file_attachement['content'] = $pdf->render(false);
|
||||
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang).sprintf('%06d', $order->invoice_number).'.pdf';
|
||||
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->invoice_number).'.pdf';
|
||||
$file_attachement['mime'] = 'application/pdf';
|
||||
}
|
||||
else
|
||||
|
||||
+3
-2
@@ -902,7 +902,7 @@ class ProductCore extends ObjectModel
|
||||
);
|
||||
|
||||
$return = Db::getInstance()->delete('category_product', 'id_product = '.(int)$this->id);
|
||||
if ($clean_positions === true)
|
||||
if ($clean_positions === true && is_array($result))
|
||||
foreach ($result as $row)
|
||||
$return &= $this->cleanPositions((int)$row['id_category']);
|
||||
|
||||
@@ -4951,7 +4951,7 @@ class ProductCore extends ObjectModel
|
||||
{
|
||||
$query->from('product_attribute', 'pa');
|
||||
$query->join(Shop::addSqlAssociation('product_attribute', 'pa'));
|
||||
$query->innerJoin('product_lang', 'pl', 'pl.id_product = pa.id_product AND pl.id_lang = '.(int)$id_lang);
|
||||
$query->innerJoin('product_lang', 'pl', 'pl.id_product = pa.id_product AND pl.id_lang = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl'));
|
||||
$query->leftJoin('product_attribute_combination', 'pac', 'pac.id_product_attribute = pa.id_product_attribute');
|
||||
$query->leftJoin('attribute', 'atr', 'atr.id_attribute = pac.id_attribute');
|
||||
$query->leftJoin('attribute_lang', 'al', 'al.id_attribute = atr.id_attribute AND al.id_lang = '.(int)$id_lang);
|
||||
@@ -4962,6 +4962,7 @@ class ProductCore extends ObjectModel
|
||||
{
|
||||
$query->from('product_lang', 'pl');
|
||||
$query->where('pl.id_product = '.(int)$id_product);
|
||||
$query->where('pl.id_lang = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl'));
|
||||
}
|
||||
|
||||
return Db::getInstance()->getValue($query);
|
||||
|
||||
+26
-8
@@ -1277,10 +1277,9 @@ class ToolsCore
|
||||
|
||||
public static function file_get_contents($url, $use_include_path = false, $stream_context = null, $curl_timeout = 5)
|
||||
{
|
||||
if ($stream_context == null)
|
||||
$stream_context = @stream_context_create(array('http' => array('timeout' => 5)));
|
||||
|
||||
if (in_array(ini_get('allow_url_fopen'), array('On', 'on', '1')))
|
||||
if ($stream_context == null && !preg_match('/^https?:\/\//', $url))
|
||||
$stream_context = @stream_context_create(array('http' => array('timeout' => $curl_timeout)));
|
||||
if (in_array(ini_get('allow_url_fopen'), array('On', 'on', '1')) || !preg_match('/^https?:\/\//', $url))
|
||||
return @file_get_contents($url, $use_include_path, $stream_context);
|
||||
elseif (function_exists('curl_init'))
|
||||
{
|
||||
@@ -1289,6 +1288,16 @@ class ToolsCore
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $curl_timeout);
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, $curl_timeout);
|
||||
$opts = stream_context_get_options($stream_context);
|
||||
if (isset($opts['http']['method']) && Tools::strtolower($opts['http']['method']) == 'post')
|
||||
{
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
if (isset($opts['http']['content']))
|
||||
{
|
||||
parse_str($opts['http']['content'], $datas);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $datas);
|
||||
}
|
||||
}
|
||||
$content = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
return $content;
|
||||
@@ -1299,10 +1308,7 @@ class ToolsCore
|
||||
|
||||
public static function simplexml_load_file($url, $class_name = null)
|
||||
{
|
||||
if (in_array(ini_get('allow_url_fopen'), array('On', 'on', '1')))
|
||||
return @simplexml_load_string(Tools::file_get_contents($url), $class_name);
|
||||
else
|
||||
return false;
|
||||
return @simplexml_load_string(Tools::file_get_contents($url), $class_name);
|
||||
}
|
||||
|
||||
|
||||
@@ -1535,6 +1541,18 @@ class ToolsCore
|
||||
'virtual' => $shop_url->virtual_uri,
|
||||
'id_shop' => $shop_url->id_shop
|
||||
);
|
||||
|
||||
if ($shop_url->domain == $shop_url->domain_ssl)
|
||||
continue;
|
||||
|
||||
if (!isset($domains[$shop_url->domain_ssl]))
|
||||
$domains[$shop_url->domain_ssl] = array();
|
||||
|
||||
$domains[$shop_url->domain_ssl][] = array(
|
||||
'physical' => $shop_url->physical_uri,
|
||||
'virtual' => $shop_url->virtual_uri,
|
||||
'id_shop' => $shop_url->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
// Write data in .htaccess file
|
||||
|
||||
Vendored
+34
-23
@@ -46,26 +46,33 @@ class CacheMemcacheCore extends Cache
|
||||
|
||||
// Get keys (this code comes from Doctrine 2 project)
|
||||
$this->keys = array();
|
||||
$all_slabs = $this->memcache->getExtendedStats('slabs');
|
||||
|
||||
foreach ($all_slabs as $server => $slabs)
|
||||
{
|
||||
if (is_array($slabs))
|
||||
{
|
||||
foreach (array_keys($slabs) as $slab_id)
|
||||
{
|
||||
$dump = $this->memcache->getExtendedStats('cachedump', (int)$slab_id);
|
||||
if ($dump)
|
||||
{
|
||||
foreach ($dump as $entries)
|
||||
{
|
||||
if ($entries)
|
||||
$this->keys = array_merge($this->keys, array_keys($entries));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$servers = self::getMemcachedServers();
|
||||
|
||||
if(is_array($servers) && count($servers) > 0 && method_exists('Memcache', 'getStats'))
|
||||
$all_slabs = $this->memcache->getStats('slabs');
|
||||
|
||||
if(isset($all_slabs) && is_array($all_slabs))
|
||||
foreach ($all_slabs as $server => $slabs)
|
||||
{
|
||||
if (is_array($slabs))
|
||||
{
|
||||
foreach (array_keys($slabs) as $slab_id)
|
||||
{
|
||||
if(is_int($slab_id))
|
||||
{
|
||||
$dump = $this->memcache->getStats('cachedump', (int)$slab_id);
|
||||
if ($dump)
|
||||
{
|
||||
foreach ($dump as $entries)
|
||||
{
|
||||
if ($entries)
|
||||
$this->keys = array_merge($this->keys, array_keys($entries));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
@@ -78,12 +85,16 @@ class CacheMemcacheCore extends Cache
|
||||
*/
|
||||
public function connect()
|
||||
{
|
||||
$this->memcache = new Memcache();
|
||||
$servers = CacheMemcache::getMemcachedServers();
|
||||
if (class_exists('Memcache') && extension_loaded('memcache'))
|
||||
$this->memcache = new Memcache();
|
||||
else
|
||||
return false;
|
||||
|
||||
$servers = self::getMemcachedServers();
|
||||
if (!$servers)
|
||||
return false;
|
||||
foreach ($servers as $server)
|
||||
$this->memcache->addServer($server['ip'], $server['port'], $server['weight']);
|
||||
$this->memcache->addServer($server['ip'], $server['port'], true, (int) $server['weight']);
|
||||
|
||||
$this->is_connected = true;
|
||||
}
|
||||
|
||||
@@ -2268,9 +2268,10 @@ class AdminControllerCore extends Controller
|
||||
$class_name = $this->className;
|
||||
|
||||
/* Class specific validation rules */
|
||||
$rules = call_user_func(array($class_name, 'getValidationRules'), $class_name);
|
||||
if (!empty($class_name))
|
||||
$rules = call_user_func(array($class_name, 'getValidationRules'), $class_name);
|
||||
|
||||
if ((count($rules['requiredLang']) || count($rules['sizeLang']) || count($rules['validateLang'])))
|
||||
if (isset($rules) && count($rules) && (count($rules['requiredLang']) || count($rules['sizeLang']) || count($rules['validateLang'])))
|
||||
{
|
||||
/* Language() instance determined by default language */
|
||||
$default_language = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
|
||||
@@ -2280,56 +2281,61 @@ class AdminControllerCore extends Controller
|
||||
}
|
||||
|
||||
/* Checking for required fields */
|
||||
foreach ($rules['required'] as $field)
|
||||
if (($value = Tools::getValue($field)) == false && (string)$value != '0')
|
||||
if (!Tools::getValue($this->identifier) || ($field != 'passwd' && $field != 'no-picture'))
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('The field %s is required.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name)
|
||||
);
|
||||
if (isset($rules['required']) && is_array($rules['required']))
|
||||
foreach ($rules['required'] as $field)
|
||||
if (($value = Tools::getValue($field)) == false && (string)$value != '0')
|
||||
if (!Tools::getValue($this->identifier) || ($field != 'passwd' && $field != 'no-picture'))
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('The field %s is required.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name)
|
||||
);
|
||||
|
||||
/* Checking for multilingual required fields */
|
||||
foreach ($rules['requiredLang'] as $field_lang)
|
||||
if (($empty = Tools::getValue($field_lang.'_'.$default_language->id)) === false || $empty !== '0' && empty($empty))
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('The field %1$s is required at least in %2$s.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||
$default_language->name
|
||||
);
|
||||
if (isset($rules['requiredLang']) && is_array($rules['requiredLang']))
|
||||
foreach ($rules['requiredLang'] as $field_lang)
|
||||
if (($empty = Tools::getValue($field_lang.'_'.$default_language->id)) === false || $empty !== '0' && empty($empty))
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('The field %1$s is required at least in %2$s.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||
$default_language->name
|
||||
);
|
||||
|
||||
/* Checking for maximum fields sizes */
|
||||
foreach ($rules['size'] as $field => $max_length)
|
||||
if (Tools::getValue($field) !== false && Tools::strlen(Tools::getValue($field)) > $max_length)
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('The field %1$s is too long (%2$d chars max).'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name),
|
||||
$max_length
|
||||
);
|
||||
|
||||
/* Checking for maximum multilingual fields size */
|
||||
foreach ($rules['sizeLang'] as $field_lang => $max_length)
|
||||
foreach ($languages as $language)
|
||||
{
|
||||
$field_lang_value = Tools::getValue($field_lang.'_'.$language['id_lang']);
|
||||
if ($field_lang_value !== false && Tools::strlen($field_lang_value) > $max_length)
|
||||
if (isset($rules['size']) && is_array($rules['size']))
|
||||
foreach ($rules['size'] as $field => $max_length)
|
||||
if (Tools::getValue($field) !== false && Tools::strlen(Tools::getValue($field)) > $max_length)
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('The field %1$s (%2$s) is too long (%3$d chars max, html chars including).'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||
$language['name'],
|
||||
Tools::displayError('The field %1$s is too long (%2$d chars max).'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name),
|
||||
$max_length
|
||||
);
|
||||
}
|
||||
|
||||
/* Checking for maximum multilingual fields size */
|
||||
if (isset($rules['sizeLang']) && is_array($rules['sizeLang']))
|
||||
foreach ($rules['sizeLang'] as $field_lang => $max_length)
|
||||
foreach ($languages as $language)
|
||||
{
|
||||
$field_lang_value = Tools::getValue($field_lang.'_'.$language['id_lang']);
|
||||
if ($field_lang_value !== false && Tools::strlen($field_lang_value) > $max_length)
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('The field %1$s (%2$s) is too long (%3$d chars max, html chars including).'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||
$language['name'],
|
||||
$max_length
|
||||
);
|
||||
}
|
||||
/* Overload this method for custom checking */
|
||||
$this->_childValidation();
|
||||
|
||||
/* Checking for fields validity */
|
||||
foreach ($rules['validate'] as $field => $function)
|
||||
if (($value = Tools::getValue($field)) !== false && ($field != 'passwd'))
|
||||
if (!Validate::$function($value) && !empty($value))
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('The field %s is invalid.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name)
|
||||
);
|
||||
if (isset($rules['validate']) && is_array($rules['validate']))
|
||||
foreach ($rules['validate'] as $field => $function)
|
||||
if (($value = Tools::getValue($field)) !== false && ($field != 'passwd'))
|
||||
if (!Validate::$function($value) && !empty($value))
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('The field %s is invalid.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name)
|
||||
);
|
||||
|
||||
/* Checking for passwd_old validity */
|
||||
if (($value = Tools::getValue('passwd')) != false)
|
||||
@@ -2347,15 +2353,16 @@ class AdminControllerCore extends Controller
|
||||
}
|
||||
|
||||
/* Checking for multilingual fields validity */
|
||||
foreach ($rules['validateLang'] as $field_lang => $function)
|
||||
foreach ($languages as $language)
|
||||
if (($value = Tools::getValue($field_lang.'_'.$language['id_lang'])) !== false && !empty($value))
|
||||
if (!Validate::$function($value))
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('The field %1$s (%2$s) is invalid.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||
$language['name']
|
||||
);
|
||||
if (isset($rules['validateLang']) && is_array($rules['validateLang']))
|
||||
foreach ($rules['validateLang'] as $field_lang => $function)
|
||||
foreach ($languages as $language)
|
||||
if (($value = Tools::getValue($field_lang.'_'.$language['id_lang'])) !== false && !empty($value))
|
||||
if (!Validate::$function($value))
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('The field %1$s (%2$s) is invalid.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||
$language['name']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -585,7 +585,7 @@ class FrontControllerCore extends Controller
|
||||
/* Display a maintenance page if shop is closed */
|
||||
protected function displayMaintenancePage()
|
||||
{
|
||||
if ($this->maintenance == true || (basename($_SERVER['PHP_SELF']) != 'disabled.php' && !(int)(Configuration::get('PS_SHOP_ENABLE'))))
|
||||
if ($this->maintenance == true || !(int)Configuration::get('PS_SHOP_ENABLE'))
|
||||
{
|
||||
$this->maintenance = true;
|
||||
if (!in_array(Tools::getRemoteAddr(), explode(',', Configuration::get('PS_MAINTENANCE_IP'))))
|
||||
|
||||
@@ -674,6 +674,11 @@ abstract class DbCore
|
||||
return call_user_func_array(array(Db::getClass(), 'hasTableWithSamePrefix'), array($server, $user, $pwd, $db, $prefix));
|
||||
}
|
||||
|
||||
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
|
||||
{
|
||||
return call_user_func_array(array(Db::getClass(), 'checkCreatePrivilege'), array($server, $user, $pwd, $db, $prefix, $engine));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 1.5.0
|
||||
*/
|
||||
|
||||
@@ -185,6 +185,25 @@ class DbMySQLiCore extends Db
|
||||
$link->close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
|
||||
{
|
||||
$link = @new mysqli($server, $user, $pwd, $db);
|
||||
if (mysqli_connect_error())
|
||||
return false;
|
||||
|
||||
$sql = '
|
||||
CREATE TABLE `'.$prefix.'test` (
|
||||
`test` tinyint(1) unsigned NOT NULL
|
||||
) ENGINE=MyISAM';
|
||||
$result = $link->query($sql);
|
||||
|
||||
if (!$result)
|
||||
return $link->error;
|
||||
|
||||
$link->query('DROP TABLE `'.$prefix.'test`');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Db::checkEncoding()
|
||||
|
||||
@@ -174,6 +174,28 @@ class DbPDOCore extends Db
|
||||
return (bool)$result->fetch();
|
||||
}
|
||||
|
||||
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
|
||||
{
|
||||
try {
|
||||
$link = DbPDO::_getPDO($server, $user, $pwd, $db, 5);
|
||||
} catch (PDOException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = '
|
||||
CREATE TABLE `'.$prefix.'test` (
|
||||
`test` tinyint(1) unsigned NOT NULL
|
||||
) ENGINE=MyISAM';
|
||||
$result = $link->query($sql);
|
||||
if (!$result)
|
||||
{
|
||||
$error = $link->errorInfo();
|
||||
return $error[2];
|
||||
}
|
||||
$link->query('DROP TABLE `'.$prefix.'test`');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Db::checkConnection()
|
||||
*/
|
||||
|
||||
@@ -174,6 +174,28 @@ class MySQLCore extends Db
|
||||
@mysql_close($link);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
|
||||
{
|
||||
ini_set('mysql.connect_timeout', 5);
|
||||
if (!$link = @mysql_connect($server, $user, $pwd, true))
|
||||
return false;
|
||||
if (!@mysql_select_db($db, $link))
|
||||
return false;
|
||||
|
||||
$sql = '
|
||||
CREATE TABLE `'.$prefix.'test` (
|
||||
`test` tinyint(1) unsigned NOT NULL
|
||||
) ENGINE=MyISAM';
|
||||
|
||||
$result = mysql_query($sql, $link);
|
||||
|
||||
if (!$result)
|
||||
return mysql_error($link);
|
||||
|
||||
mysql_query('DROP TABLE `'.$prefix.'test`', $link);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Db::checkEncoding()
|
||||
|
||||
@@ -189,7 +189,10 @@ abstract class ModuleCore
|
||||
{
|
||||
// Check module name validation
|
||||
if (!Validate::isModuleName($this->name))
|
||||
die(Tools::displayError());
|
||||
{
|
||||
$this->_errors[] = $this->l('Unable to install the module (Module name is not valid).');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check PS version compliancy
|
||||
if (version_compare(_PS_VERSION_, $this->ps_versions_compliancy['min']) < 0 || version_compare(_PS_VERSION_, $this->ps_versions_compliancy['max']) >= 0)
|
||||
|
||||
+17
-11
@@ -264,7 +264,7 @@ class OrderCore extends ObjectModel
|
||||
public function getFields()
|
||||
{
|
||||
if (!$this->id_lang)
|
||||
$this->id_lang = Configuration::get('PS_LANG_DEFAULT');
|
||||
$this->id_lang = Configuration::get('PS_LANG_DEFAULT', null, null, $this->id_shop);
|
||||
|
||||
return parent::getFields();
|
||||
}
|
||||
@@ -289,7 +289,7 @@ class OrderCore extends ObjectModel
|
||||
|
||||
if ($this->hasBeenDelivered())
|
||||
{
|
||||
if (!Configuration::get('PS_ORDER_RETURN'))
|
||||
if (!Configuration::get('PS_ORDER_RETURN', null, null, $this->id_shop))
|
||||
throw new PrestaShopException('PS_ORDER_RETURN is not defined in table configuration');
|
||||
$orderDetail->product_quantity_return += (int)($quantity);
|
||||
return $orderDetail->update();
|
||||
@@ -1027,7 +1027,7 @@ class OrderCore extends ObjectModel
|
||||
* @param int $id_order_invoice
|
||||
* @return bool
|
||||
*/
|
||||
public function addCartRule($id_cart_rule, $name, $values, $id_order_invoice = 0)
|
||||
public function addCartRule($id_cart_rule, $name, $values, $id_order_invoice = 0, $free_shipping = null)
|
||||
{
|
||||
$order_cart_rule = new OrderCartRule();
|
||||
$order_cart_rule->id_order = $this->id;
|
||||
@@ -1036,12 +1036,18 @@ class OrderCore extends ObjectModel
|
||||
$order_cart_rule->name = $name;
|
||||
$order_cart_rule->value = $values['tax_incl'];
|
||||
$order_cart_rule->value_tax_excl = $values['tax_excl'];
|
||||
if ($free_shipping === null)
|
||||
{
|
||||
$cart_rule = new CartRule($id_cart_rule);
|
||||
$free_shipping = $cart_rule->free_shipping;
|
||||
}
|
||||
$order_cart_rule->free_shipping = (int)$free_shipping;
|
||||
$order_cart_rule->add();
|
||||
}
|
||||
|
||||
public function getNumberOfDays()
|
||||
{
|
||||
$nbReturnDays = (int)(Configuration::get('PS_ORDER_RETURN_NB_DAYS'));
|
||||
$nbReturnDays = (int)(Configuration::get('PS_ORDER_RETURN_NB_DAYS', null, null, $this->id_shop));
|
||||
if (!$nbReturnDays)
|
||||
return true;
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
@@ -1059,7 +1065,7 @@ class OrderCore extends ObjectModel
|
||||
*/
|
||||
public function isReturnable()
|
||||
{
|
||||
if (Configuration::get('PS_ORDER_RETURN') && $this->isPaidAndShipped())
|
||||
if (Configuration::get('PS_ORDER_RETURN', null, null, $this->id_shop) && $this->isPaidAndShipped())
|
||||
return $this->getNumberOfDays();
|
||||
|
||||
return false;
|
||||
@@ -1082,10 +1088,10 @@ class OrderCore extends ObjectModel
|
||||
{
|
||||
$order_invoice = new OrderInvoice();
|
||||
$order_invoice->id_order = $this->id;
|
||||
$order_invoice->number = Configuration::get('PS_INVOICE_START_NUMBER');
|
||||
$order_invoice->number = Configuration::get('PS_INVOICE_START_NUMBER', null, null, $this->id_shop);
|
||||
// If invoice start number has been set, you clean the value of this configuration
|
||||
if ($order_invoice->number)
|
||||
Configuration::updateValue('PS_INVOICE_START_NUMBER', false );
|
||||
Configuration::updateValue('PS_INVOICE_START_NUMBER', false, false, null, $this->id_shop);
|
||||
else
|
||||
$order_invoice->number = Order::getLastInvoiceNumber() + 1;
|
||||
|
||||
@@ -1169,11 +1175,11 @@ class OrderCore extends ObjectModel
|
||||
$order_invoice_collection = $this->getInvoicesCollection();
|
||||
foreach ($order_invoice_collection as $order_invoice)
|
||||
{
|
||||
$number = (int)Configuration::get('PS_DELIVERY_NUMBER');
|
||||
$number = (int)Configuration::get('PS_DELIVERY_NUMBER', null, null, $this->id_shop);
|
||||
if (!$number)
|
||||
{
|
||||
//if delivery number is not set or wrong, we set a default one.
|
||||
Configuration::updateValue('PS_DELIVERY_NUMBER', 1);
|
||||
Configuration::updateValue('PS_DELIVERY_NUMBER', 1, false, null, $this->id_shop);
|
||||
$number = 1;
|
||||
}
|
||||
|
||||
@@ -1185,7 +1191,7 @@ class OrderCore extends ObjectModel
|
||||
|
||||
// Keep for backward compatibility
|
||||
$this->delivery_number = $number;
|
||||
Configuration::updateValue('PS_DELIVERY_NUMBER', $number + 1);
|
||||
Configuration::updateValue('PS_DELIVERY_NUMBER', $number + 1, false, null, $this->id_shop);
|
||||
}
|
||||
|
||||
// Keep it for backward compatibility, to remove on 1.6 version
|
||||
@@ -1591,7 +1597,7 @@ class OrderCore extends ObjectModel
|
||||
else
|
||||
{
|
||||
$amount = Tools::convertPrice($payment->amount, $payment->id_currency, false);
|
||||
if ($currency->id == Configuration::get('PS_DEFAULT_CURRENCY'))
|
||||
if ($currency->id == Configuration::get('PS_DEFAULT_CURRENCY', null, null, $this->id_shop))
|
||||
$total += $amount;
|
||||
else
|
||||
$total += Tools::convertPrice($amount, $currency->id, true);
|
||||
|
||||
@@ -70,10 +70,10 @@ class OrderHistoryCore extends ObjectModel
|
||||
* Sets the new state of the given order
|
||||
*
|
||||
* @param int $new_order_state
|
||||
* @param int $id_order
|
||||
* @param int/object $id_order
|
||||
* @param bool $use_existing_payment
|
||||
*/
|
||||
public function changeIdOrderState($new_order_state, &$id_order, $use_existing_payment = false)
|
||||
public function changeIdOrderState($new_order_state, $id_order, $use_existing_payment = false)
|
||||
{
|
||||
if (!$new_order_state || !$id_order)
|
||||
return;
|
||||
@@ -210,7 +210,7 @@ class OrderHistoryCore extends ObjectModel
|
||||
// if the product is a pack, we restock every products in the pack using the last negative stock mvts
|
||||
if (Pack::isPack($product['product_id']))
|
||||
{
|
||||
$pack_products = Pack::getItems($product['product_id'], Configuration::get('PS_LANG_DEFAULT'));
|
||||
$pack_products = Pack::getItems($product['product_id'], Configuration::get('PS_LANG_DEFAULT', null, null, $order->id_shop));
|
||||
foreach ($pack_products as $pack_product)
|
||||
{
|
||||
if ($pack_product->advanced_stock_management == 1)
|
||||
|
||||
@@ -345,6 +345,11 @@ class OrderInvoiceCore extends ObjectModel
|
||||
// shipping cost are added in the product taxes breakdown
|
||||
if ($this->useOneAfterAnotherTaxComputationMethod())
|
||||
return $taxes_breakdown;
|
||||
|
||||
// No shipping breakdown if it's free!
|
||||
foreach ($order->getCartRules() as $cart_rule)
|
||||
if ($cart_rule['free_shipping'])
|
||||
return $taxes_breakdown;
|
||||
|
||||
$shipping_tax_amount = $this->total_shipping_tax_incl - $this->total_shipping_tax_excl;
|
||||
|
||||
@@ -654,9 +659,9 @@ class OrderInvoiceCore extends ObjectModel
|
||||
* @param int $id_lang for invoice_prefix
|
||||
* @return string
|
||||
*/
|
||||
public function getInvoiceNumberFormatted($id_lang)
|
||||
public function getInvoiceNumberFormatted($id_lang, $id_shop = null)
|
||||
{
|
||||
return '#'.Configuration::get('PS_INVOICE_PREFIX', $id_lang).sprintf('%06d', $this->number);
|
||||
return '#'.Configuration::get('PS_INVOICE_PREFIX', $id_lang, null, $id_shop).sprintf('%06d', $this->number);
|
||||
}
|
||||
|
||||
public function saveCarrierTaxCalculator(array $taxes_amount)
|
||||
|
||||
@@ -225,11 +225,12 @@ class OrderReturnCore extends ObjectModel
|
||||
public static function addReturnedQuantity(&$products, $id_order)
|
||||
{
|
||||
$details = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT od.id_order_detail, GREATEST(od.product_quantity_return, IFNULL(ord.product_quantity,0)) as qty_returned
|
||||
SELECT od.id_order_detail, GREATEST(od.product_quantity_return, IFNULL(SUM(ord.product_quantity),0)) as qty_returned
|
||||
FROM '._DB_PREFIX_.'order_detail od
|
||||
LEFT JOIN '._DB_PREFIX_.'order_return_detail ord
|
||||
ON ord.id_order_detail = od.id_order_detail
|
||||
WHERE od.id_order = '.(int)$id_order
|
||||
WHERE od.id_order = '.(int)$id_order.'
|
||||
GROUP BY od.id_order_detail'
|
||||
);
|
||||
if (!$details)
|
||||
return;
|
||||
|
||||
@@ -42,7 +42,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
|
||||
$this->date = Tools::displayDate($order_invoice->date_add, (int)$this->order->id_lang);
|
||||
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
$this->title = HTMLTemplateInvoice::l('Invoice ').' #'.Configuration::get('PS_INVOICE_PREFIX', $id_lang).sprintf('%06d', $order_invoice->number);
|
||||
$this->title = HTMLTemplateInvoice::l('Invoice ').' #'.Configuration::get('PS_INVOICE_PREFIX', $id_lang, null, (int)$this->order->id_shop).sprintf('%06d', $order_invoice->number);
|
||||
// footer informations
|
||||
$this->shop = new Shop((int)$this->order->id_shop);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user