Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into development
This commit is contained in:
+7
-2
@@ -953,6 +953,7 @@ class CartCore extends ObjectModel
|
||||
$this->update(true);
|
||||
$context = Context::getContext()->cloneContext();
|
||||
$context->cart = $this;
|
||||
Cache::clean('getContextualValue_*');
|
||||
if ($auto_add_cart_rule)
|
||||
CartRule::autoAddToCart($context);
|
||||
|
||||
@@ -2869,8 +2870,12 @@ class CartCore extends ObjectModel
|
||||
{
|
||||
$cart_rule['value_real'] -= $total_shipping;
|
||||
$cart_rule['value_tax_exc'] -= $total_shipping_tax_exc;
|
||||
$total_discounts -= $total_shipping;
|
||||
$total_discounts_tax_exc -= $total_shipping_tax_exc;
|
||||
$cart_rule['value_real'] = Tools::ps_round($cart_rule['value_real'], (int)$context->currency->decimals * _PS_PRICE_DISPLAY_PRECISION_);
|
||||
$cart_rule['value_tax_exc'] = Tools::ps_round($cart_rule['value_tax_exc'], (int)$context->currency->decimals * _PS_PRICE_DISPLAY_PRECISION_);
|
||||
if ($total_discounts > $cart_rule['value_real'])
|
||||
$total_discounts -= $total_shipping;
|
||||
if ($total_discounts_tax_exc > $cart_rule['value_tax_exc'])
|
||||
$total_discounts_tax_exc -= $total_shipping_tax_exc;
|
||||
|
||||
// Update total shipping
|
||||
$total_shipping = 0;
|
||||
|
||||
@@ -912,7 +912,7 @@ class CartRuleCore extends ObjectModel
|
||||
if ($cart_vat_amount == 0 || $cart_amount_te == 0)
|
||||
$cart_average_vat_rate = 0;
|
||||
else
|
||||
$cart_average_vat_rate = $cart_vat_amount / $cart_amount_te;
|
||||
$cart_average_vat_rate = Tools::ps_round($cart_vat_amount / $cart_amount_te, 3);
|
||||
|
||||
if ($this->reduction_tax && !$use_tax)
|
||||
$reduction_value += $prorata * $reduction_amount / (1 + $cart_average_vat_rate);
|
||||
@@ -1079,12 +1079,12 @@ class CartRuleCore extends ObjectModel
|
||||
if (!CartRule::isFeatureActive() || !Validate::isLoadedObject($context->cart))
|
||||
return;
|
||||
|
||||
$result = Db::getInstance()->executeS('
|
||||
$sql = '
|
||||
SELECT cr.*
|
||||
FROM '._DB_PREFIX_.'cart_rule cr
|
||||
LEFT JOIN '._DB_PREFIX_.'cart_rule_shop crs ON cr.id_cart_rule = crs.id_cart_rule
|
||||
LEFT JOIN '._DB_PREFIX_.'cart_rule_carrier crca ON cr.id_cart_rule = crca.id_cart_rule
|
||||
'.($context->cart->id_carrier ? 'INNER JOIN '._DB_PREFIX_.'carrier c ON (c.id_reference = crca.id_carrier AND c.deleted = 0)' : '').'
|
||||
'.($context->cart->id_carrier ? 'LEFT JOIN '._DB_PREFIX_.'carrier c ON (c.id_reference = crca.id_carrier AND c.deleted = 0)' : '').'
|
||||
LEFT JOIN '._DB_PREFIX_.'cart_rule_country crco ON cr.id_cart_rule = crco.id_cart_rule
|
||||
WHERE cr.active = 1
|
||||
AND cr.code = ""
|
||||
@@ -1108,9 +1108,9 @@ class CartRuleCore extends ObjectModel
|
||||
'.($context->customer->id ? 'OR 0 < (
|
||||
SELECT cg.id_group
|
||||
FROM '._DB_PREFIX_.'customer_group cg
|
||||
LEFT JOIN '._DB_PREFIX_.'cart_rule_group crg ON cg.id_group = crg.id_group
|
||||
LEFT JOIN '._DB_PREFIX_.'cart_rule_group crg ON (cg.id_group = crg.id_group AND cg.id_group = '.(int)$context->customer->id_default_group.')
|
||||
WHERE cr.id_cart_rule = crg.id_cart_rule
|
||||
AND cg.id_customer = '.(int)$context->customer->id.'
|
||||
AND cg.id_customer = '.(int)$context->customer->id.' LIMIT 1
|
||||
)' : '').'
|
||||
)
|
||||
AND (
|
||||
@@ -1122,8 +1122,8 @@ class CartRuleCore extends ObjectModel
|
||||
)
|
||||
)
|
||||
AND cr.id_cart_rule NOT IN (SELECT id_cart_rule FROM '._DB_PREFIX_.'cart_cart_rule WHERE id_cart = '.(int)$context->cart->id.')
|
||||
ORDER BY priority');
|
||||
|
||||
ORDER BY priority';
|
||||
$result = Db::getInstance()->executeS($sql);
|
||||
if ($result)
|
||||
{
|
||||
$cart_rules = ObjectModel::hydrateCollection('CartRule', $result);
|
||||
|
||||
@@ -801,6 +801,8 @@ class LanguageCore extends ObjectModel
|
||||
$files_list = $gz->listContent();
|
||||
if (!$gz->extract(_PS_TRANSLATIONS_DIR_.'../', false))
|
||||
$errors[] = Tools::displayError('Cannot decompress the translation file for the following language: ').(string)$iso;
|
||||
// Clear smarty modules cache
|
||||
Tools::clearCache();
|
||||
if (!Language::checkAndAddLanguage((string)$iso, $lang_pack, false, $params))
|
||||
$errors[] = Tools::displayError('An error occurred while creating the language: ').(string)$iso;
|
||||
else
|
||||
|
||||
+1
-1
@@ -251,7 +251,7 @@ class MailCore
|
||||
$template_vars['{shop_logo}'] = $message->attach(new Swift_Message_EmbeddedFile(new Swift_File($logo), null, ImageManager::getMimeTypeByExtension($logo)));
|
||||
|
||||
$template_vars['{shop_name}'] = Tools::safeOutput(Configuration::get('PS_SHOP_NAME', null, null, $id_shop));
|
||||
$template_vars['{shop_url}'] = Tools::getShopDomain(true, true).__PS_BASE_URI__.'index.php';
|
||||
$template_vars['{shop_url}'] = Context::getContext()->link->getPageLink('index', true, Context::getContext()->language->id);
|
||||
$template_vars['{my_account_url}'] = Context::getContext()->link->getPageLink('my-account', true, Context::getContext()->language->id);
|
||||
$template_vars['{guest_tracking_url}'] = Context::getContext()->link->getPageLink('guest-tracking', true, Context::getContext()->language->id);
|
||||
$template_vars['{history_url}'] = Context::getContext()->link->getPageLink('history', true, Context::getContext()->language->id);
|
||||
|
||||
@@ -429,12 +429,14 @@ abstract class PaymentModuleCore extends Module
|
||||
|
||||
// Set the new voucher value
|
||||
if ($voucher->reduction_tax)
|
||||
$voucher->reduction_amount = $values['tax_incl'] - $order->total_products_wt;
|
||||
$voucher->reduction_amount = $values['tax_incl'] - $order->total_products_wt - $order->total_shipping_tax_incl;
|
||||
else
|
||||
$voucher->reduction_amount = $values['tax_excl'] - $order->total_products;
|
||||
$voucher->reduction_amount = $values['tax_excl'] - $order->total_products - $order->total_shipping_tax_excl;
|
||||
|
||||
$voucher->id_customer = $order->id_customer;
|
||||
$voucher->quantity = 1;
|
||||
$voucher->quantity_per_user = 1;
|
||||
$voucher->free_shipping = 0;
|
||||
if ($voucher->add())
|
||||
{
|
||||
// If the voucher has conditions, they are now copied to the new voucher
|
||||
|
||||
+8
-1
@@ -458,6 +458,10 @@ class ProductCore extends ObjectModel
|
||||
$this->tax_rate = $this->getTaxesRate(new Address($address));
|
||||
|
||||
$this->new = $this->isNew();
|
||||
|
||||
// keep base price
|
||||
$this->base_price = $this->price;
|
||||
|
||||
$this->price = Product::getPriceStatic((int)$this->id, false, null, 6, null, false, true, 1, false, null, null, null, $this->specificPrice);
|
||||
$this->unit_price = ($this->unit_price_ratio != 0 ? $this->price / $this->unit_price_ratio : 0);
|
||||
if ($this->id)
|
||||
@@ -2135,7 +2139,10 @@ class ProductCore extends ObjectModel
|
||||
|
||||
$sql = 'SELECT p.*, product_shop.*, stock.`out_of_stock` out_of_stock, pl.`description`, pl.`description_short`,
|
||||
pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`,
|
||||
p.`ean13`, p.`upc`, MAX(image_shop.`id_image`) id_image, il.`legend`
|
||||
p.`ean13`, p.`upc`, MAX(image_shop.`id_image`) id_image, il.`legend`,
|
||||
DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(),
|
||||
INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).'
|
||||
DAY)) > 0 AS new
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
||||
p.`id_product` = pl.`id_product`
|
||||
|
||||
+7
-7
@@ -2119,7 +2119,7 @@ exit;
|
||||
*
|
||||
* @param Smarty $smarty
|
||||
*/
|
||||
public static function clearCache($smarty, $tpl = false, $cache_id = null, $compile_id = null)
|
||||
public static function clearCache($smarty = null, $tpl = false, $cache_id = null, $compile_id = null)
|
||||
{
|
||||
if (is_null($smarty))
|
||||
$smarty = Context::getContext()->smarty;
|
||||
@@ -2349,16 +2349,16 @@ exit;
|
||||
$addons_url = 'api.addons.prestashop.com';
|
||||
$postData = '';
|
||||
$postDataArray = array(
|
||||
'version' => _PS_VERSION_,
|
||||
'iso_lang' => strtolower(Context::getContext()->language->iso_code),
|
||||
'iso_code' => strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))),
|
||||
'shop_url' => urlencode(Tools::getShopDomain()),
|
||||
'mail' => urlencode(Configuration::get('PS_SHOP_EMAIL'))
|
||||
'version' => isset($params['version']) ? $params['version'] : _PS_VERSION_,
|
||||
'iso_lang' => Tools::strtolower(isset($params['iso_lang']) ? $params['iso_lang'] : Context::getContext()->language->iso_code),
|
||||
'iso_code' => Tools::strtolower(isset($params['iso_country']) ? $params['iso_country'] : Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))),
|
||||
'shop_url' => urlencode(isset($params['shop_url']) ? $params['shop_url'] : Tools::getShopDomain()),
|
||||
'mail' => urlencode(isset($params['email']) ? $params['email'] : Configuration::get('email'))
|
||||
);
|
||||
foreach ($postDataArray as $postDataKey => $postDataValue)
|
||||
$postData .= '&'.$postDataKey.'='.$postDataValue;
|
||||
$postData = ltrim($postData, '&');
|
||||
|
||||
|
||||
// Config for each request
|
||||
if ($request == 'native')
|
||||
{
|
||||
|
||||
@@ -176,7 +176,7 @@ abstract class ControllerCore
|
||||
if ($this->ajax)
|
||||
{
|
||||
$action = Tools::getValue('action');
|
||||
if (!empty($action) && method_exists($this, 'displayAjax'.Tools::toCamelCase($action, true)))
|
||||
if (!empty($action) && method_exists($this, 'displayAjax'.Tools::toCamelCase($action, true)))
|
||||
$this->{'displayAjax'.$action}();
|
||||
elseif (method_exists($this, 'displayAjax'))
|
||||
$this->displayAjax();
|
||||
|
||||
@@ -60,7 +60,7 @@ abstract class ModuleCore
|
||||
/** @var int need_instance */
|
||||
public $need_instance = 1;
|
||||
|
||||
/** @var string Admin tab correponding to the module */
|
||||
/** @var string Admin tab corresponding to the module */
|
||||
public $tab = null;
|
||||
|
||||
/** @var boolean Status */
|
||||
@@ -1597,7 +1597,7 @@ abstract class ModuleCore
|
||||
{
|
||||
if ($name === null)
|
||||
$name = $this->name;
|
||||
return $name.'|'.(int)$this->context->shop->id.'|'.(int)Group::getCurrent()->id.'|'.(int)$this->context->language->id;
|
||||
return $name.'|'.(int)Tools::usingSecureMode().'|'.(int)$this->context->shop->id.'|'.(int)Group::getCurrent()->id.'|'.(int)$this->context->language->id;
|
||||
}
|
||||
|
||||
public function display($file, $template, $cacheId = null, $compileId = null)
|
||||
|
||||
@@ -33,7 +33,7 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
/**
|
||||
* @var string The extension of the image to display
|
||||
*/
|
||||
protected $imgExtension = 'jpg';
|
||||
protected $imgExtension;
|
||||
|
||||
/**
|
||||
* @var array The type of images (general, categories, manufacturers, suppliers, stores...)
|
||||
@@ -119,10 +119,18 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
// display image content if needed
|
||||
else if ($this->imgToDisplay)
|
||||
{
|
||||
if(empty($this->imgExtension)){
|
||||
$imginfo = getimagesize($this->imgToDisplay);
|
||||
$this->imgExtension = image_type_to_extension($imginfo[2],false);
|
||||
}
|
||||
|
||||
$imageResource = false;
|
||||
$types = array('jpg' => array('function' => 'imagecreatefromjpeg', 'Content-Type' => 'image/jpeg'),
|
||||
'gif' => array('function' => 'imagecreatefromgif', 'Content-Type' => 'image/gif')
|
||||
);
|
||||
$types = array(
|
||||
'jpg' => array('function' => 'imagecreatefromjpeg', 'Content-Type' => 'image/jpeg'),
|
||||
'jpeg' => array('function' => 'imagecreatefromjpeg', 'Content-Type' => 'image/jpeg'),
|
||||
'png' => array('function' => 'imagecreatefrompng', 'Content-Type' => 'image/png'),
|
||||
'gif' => array('function' => 'imagecreatefromgif', 'Content-Type' => 'image/gif')
|
||||
);
|
||||
|
||||
if (array_key_exists($this->imgExtension, $types))
|
||||
$imageResource = @$types[$this->imgExtension]['function']($this->imgToDisplay);
|
||||
|
||||
Reference in New Issue
Block a user