diff --git a/admin-dev/themes/default/template/controllers/orders/form.tpl b/admin-dev/themes/default/template/controllers/orders/form.tpl index 34a5d7cec..6e4597092 100755 --- a/admin-dev/themes/default/template/controllers/orders/form.tpl +++ b/admin-dev/themes/default/template/controllers/orders/form.tpl @@ -656,11 +656,11 @@ var id_product = Number(this.id_product); var id_product_attribute = Number(this.id_product_attribute); cart_quantity[Number(this.id_product)+'_'+Number(this.id_product_attribute)+'_'+Number(this.id_customization)] = this.cart_quantity; - cart_content += ''+this.name+'
'+this.attributes_small+''+this.reference+''; + cart_content += ''+this.name+'
'+this.attributes_small+''+this.reference+''; cart_content += (!this.id_customization ? '

' : ''); cart_content += (!this.id_customization ? '
' : ''); cart_content += (!this.id_customization ? '
' : ''); - cart_content += '' + formatCurrency(parseFloat(this.total.replace(',', '.')), currency_format, currency_sign, currency_blank) + ''; + cart_content += '' + formatCurrency(this.numeric_total, currency_format, currency_sign, currency_blank) + ''; if (this.id_customization && this.id_customization != 0) { diff --git a/classes/FeatureValue.php b/classes/FeatureValue.php index 25c0fb4fd..4580966c3 100644 --- a/classes/FeatureValue.php +++ b/classes/FeatureValue.php @@ -128,32 +128,36 @@ class FeatureValueCore extends ObjectModel return $tab['value']; } - public static function addFeatureValueImport($id_feature, $value, $id_product = null, $id_lang = null) + public static function addFeatureValueImport($id_feature, $value, $id_product = null, $id_lang = null, $custom = false) { $id_feature_value = false; if (!is_null($id_product) && $id_product) { $id_feature_value = Db::getInstance()->getValue(' - SELECT `id_feature_value` - FROM '._DB_PREFIX_.'feature_product - WHERE `id_feature` = '.(int)$id_feature.' - AND `id_product` = '.(int)$id_product); + SELECT fp.`id_feature_value` + FROM '._DB_PREFIX_.'feature_product fp + INNER JOIN '._DB_PREFIX_.'feature_value fv USING (`id_feature_value`) + WHERE fp.`id_feature` = '.(int)$id_feature.' + AND fv.`custom` = '.(int)$custom.' + AND fp.`id_product` = '.(int)$id_product); - if ($id_feature_value && !is_null($id_lang) && $id_lang) + if ($custom && $id_feature_value && !is_null($id_lang) && $id_lang) Db::getInstance()->execute(' UPDATE '._DB_PREFIX_.'feature_value_lang SET `value` = \''.pSQL($value).'\' WHERE `id_feature_value` = '.(int)$id_feature_value.' + AND `value` != \''.pSQL($value).'\' AND `id_lang` = '.(int)$id_lang); } - - if (!$id_feature_value) + + if (!$custom) $id_feature_value = Db::getInstance()->getValue(' SELECT fv.`id_feature_value` FROM '._DB_PREFIX_.'feature_value fv - LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.`id_feature_value` = fv.`id_feature_value`) + LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.`id_feature_value` = fv.`id_feature_value` AND fvl.`id_lang` = '.(int)$id_lang.') WHERE `value` = \''.pSQL($value).'\' AND fv.`id_feature` = '.(int)$id_feature.' + AND fv.`custom` = 0 GROUP BY fv.`id_feature_value`'); if ($id_feature_value) @@ -162,7 +166,7 @@ class FeatureValueCore extends ObjectModel // Feature doesn't exist, create it $feature_value = new FeatureValue(); $feature_value->id_feature = (int)$id_feature; - $feature_value->custom = 0; + $feature_value->custom = (bool)$custom; foreach (Language::getLanguages() as $language) $feature_value->value[$language['id_lang']] = $value; $feature_value->add(); diff --git a/classes/Product.php b/classes/Product.php index 5d7330cff..0d54b9752 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -3590,6 +3590,7 @@ class ProductCore extends ObjectModel if ($result3) { $result3['id_feature_value'] = $new_id_feature_value; + $result3['value'] = pSQL($result3['value']); $return &= Db::getInstance()->insert('feature_value_lang', $result3); } } diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index 309c37e40..517934d9a 100755 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -551,6 +551,8 @@ class AdminCartsControllerCore extends AdminController if (count($summary['products'])) foreach ($summary['products'] as &$product) { + $product['numeric_price'] = $product['price']; + $product['numeric_total'] = $product['total']; $product['price'] = str_replace($currency->sign, '', Tools::displayPrice($product['price'], $currency)); $product['total'] = str_replace($currency->sign, '', Tools::displayPrice($product['total'], $currency)); $product['image_link'] = $this->context->link->getImageLink($product['link_rewrite'], $product['id_image'], 'small_default'); diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index 8ae22ff07..c8ea39bb2 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -247,7 +247,7 @@ class AdminImportControllerCore extends AdminController 'delete_existing_images' => array( 'label' => $this->l('Delete existing images (0 = No, 1 = Yes)') ), - 'features' => array('label' => $this->l('Feature(Name:Value:Position)')), + 'features' => array('label' => $this->l('Feature(Name:Value:Position:Customized)')), 'online_only' => array('label' => $this->l('Available online only (0 = No, 1 = Yes)')), 'condition' => array('label' => $this->l('Condition')), 'customizable' => array('label' => $this->l('Customizable (0 = No, 1 = Yes)')), @@ -472,9 +472,8 @@ class AdminImportControllerCore extends AdminController } - $this->separator = Tools::substr(strval(trim(Tools::getValue('separator', ','))), 0, 1); - $this->multiple_value_separator = Tools::substr(strval(trim(Tools::getValue('multiple_value_separator', ';'))), 0, 1); - + $this->separator = ($separator = Tools::substr(strval(trim(Tools::getValue('separator'))), 0, 1)) ? $separator : ';'; + $this->multiple_value_separator = ($separator = Tools::substr(strval(trim(Tools::getValue('multiple_value_separator'))), 0, 1)) ? $separator : ','; parent::__construct(); } @@ -569,8 +568,8 @@ class AdminImportControllerCore extends AdminController $this->context->cookie->entity_selected = (int)Tools::getValue('entity'); $this->context->cookie->iso_lang_selected = base64_encode(Tools::getValue('iso_lang')); - $this->context->cookie->separator_selected = base64_encode(Tools::getValue('separator')); - $this->context->cookie->multiple_value_separator_selected = base64_encode(Tools::getValue('multiple_value_separator')); + $this->context->cookie->separator_selected = base64_encode($this->separator); + $this->context->cookie->multiple_value_separator_selected = base64_encode($this->multiple_value_separator); $this->context->cookie->csv_selected = base64_encode(Tools::getValue('csv')); $this->tpl_view_vars = array( @@ -1138,7 +1137,7 @@ class AdminImportControllerCore extends AdminController else $product = new Product(); - if (array_key_exists('id', $info) && (int)$info['id'] && Product::existsInDatabase((int)$info['id'], 'product')) + if (isset($product->id) && $product->id && Product::existsInDatabase((int)$product->id, 'product')) { $product->loadStockData(); $category_data = Product::getProductCategories((int)$product->id); @@ -1602,13 +1601,14 @@ class AdminImportControllerCore extends AdminController $feature_name = isset($tab_feature[0]) ? trim($tab_feature[0]) : ''; $feature_value = isset($tab_feature[1]) ? trim($tab_feature[1]) : ''; $position = isset($tab_feature[2]) ? (int)$tab_feature[2] : false; + $custom = isset($tab_feature[3]) ? (int)$tab_feature[3] : false; if(!empty($feature_name) && !empty($feature_value)) { $id_feature = (int)Feature::addFeatureImport($feature_name, $position); $id_product = null; if (Tools::getValue('forceIDs') || Tools::getValue('match_ref')) $id_product = (int)$product->id; - $id_feature_value = (int)FeatureValue::addFeatureValueImport($id_feature, $feature_value, $id_product, $id_lang); + $id_feature_value = (int)FeatureValue::addFeatureValueImport($id_feature, $feature_value, $id_product, $id_lang, $custom); Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value); } } @@ -1626,7 +1626,6 @@ class AdminImportControllerCore extends AdminController StockAvailable::setQuantity((int)$product->id, 0, $product->quantity, $this->context->shop->id); } - $this->closeCsvFile($handle); } diff --git a/controllers/admin/AdminSupplyOrdersController.php b/controllers/admin/AdminSupplyOrdersController.php index 5d581be0f..659d8fc07 100644 --- a/controllers/admin/AdminSupplyOrdersController.php +++ b/controllers/admin/AdminSupplyOrdersController.php @@ -1387,7 +1387,9 @@ class AdminSupplyOrdersControllerCore extends AdminController true, $supply_order->id); - if (!$res) + if ($res) + StockAvailable::synchronize($supply_order_detail->id_product); + else $this->errors[] = Tools::displayError($this->l('Something went wrong when adding products to the warehouse.')); $location = Warehouse::getProductLocation($supply_order_detail->id_product, diff --git a/controllers/admin/AdminTranslationsController.php b/controllers/admin/AdminTranslationsController.php index 57ad71856..d5fe4b7db 100644 --- a/controllers/admin/AdminTranslationsController.php +++ b/controllers/admin/AdminTranslationsController.php @@ -1221,6 +1221,8 @@ class AdminTranslationsControllerCore extends AdminController // Set the path of selected theme if ($this->theme_selected) define('_PS_THEME_SELECTED_DIR_', _PS_ROOT_DIR_.'/themes/'.$this->theme_selected.'/'); + else + define('_PS_THEME_SELECTED_DIR_', ''); // Get type of translation if (($type = Tools::getValue('type')) && !is_array($type)) diff --git a/js/tools.js b/js/tools.js index 4da024b8c..276eaf27c 100644 --- a/js/tools.js +++ b/js/tools.js @@ -73,7 +73,7 @@ function formatCurrency(price, currencyFormat, currencySign, currencyBlank) if (currencyFormat == 4) return (formatNumber(price, priceDisplayPrecision, ',', '.') + blank + currencySign); if (currencyFormat == 5) - return (formatNumber(price, priceDisplayPrecision, ' ', '.') + blank + currencySign); + return (currencySign + blank + formatNumber(price, priceDisplayPrecision, '\'', '.')); return price; } diff --git a/modules/loyalty/LoyaltyModule.php b/modules/loyalty/LoyaltyModule.php index 4a10126fd..cb2c51974 100644 --- a/modules/loyalty/LoyaltyModule.php +++ b/modules/loyalty/LoyaltyModule.php @@ -88,7 +88,9 @@ class LoyaltyModule extends ObjectModel $currentContext = Context::getContext(); $context = clone $currentContext; $context->cart = $cart; - $context->customer = new Customer($context->cart->id_customer); + // if customer is logged we do not recreate it + if(!$context->customer->isLogged(true)) + $context->customer = new Customer($context->cart->id_customer); $context->language = new Language($context->cart->id_lang); $context->shop = new Shop($context->cart->id_shop); $context->currency = new Currency($context->cart->id_currency, null, $context->shop->id); diff --git a/pdf/invoice-b2b.tpl b/pdf/invoice-b2b.tpl index 0fc86cba0..6f7ba9462 100755 --- a/pdf/invoice-b2b.tpl +++ b/pdf/invoice-b2b.tpl @@ -151,7 +151,7 @@ {if (isset($order_detail.reduction_amount) && $order_detail.reduction_amount > 0)} -{displayPrice currency=$order->id_currency price=$order_detail.reduction_amount} - {else if (isset($order_detail.reduction_percent) && $order_detail.reduction_percent > 0)} + {elseif (isset($order_detail.reduction_percent) && $order_detail.reduction_percent > 0)} -{$order_detail.reduction_percent}% {else} -- @@ -289,4 +289,4 @@ {/if} - \ No newline at end of file + diff --git a/pdf/invoice.tpl b/pdf/invoice.tpl index 1f48322ce..918cdb15d 100755 --- a/pdf/invoice.tpl +++ b/pdf/invoice.tpl @@ -147,7 +147,7 @@ {if (isset($order_detail.reduction_amount) && $order_detail.reduction_amount > 0)} -{displayPrice currency=$order->id_currency price=$order_detail.reduction_amount} - {else if (isset($order_detail.reduction_percent) && $order_detail.reduction_percent > 0)} + {elseif (isset($order_detail.reduction_percent) && $order_detail.reduction_percent > 0)} -{$order_detail.reduction_percent}% {else} -- diff --git a/themes/default/js/tools.js b/themes/default/js/tools.js index 4215f7a88..7b670168c 100644 --- a/themes/default/js/tools.js +++ b/themes/default/js/tools.js @@ -95,7 +95,7 @@ function formatCurrency(price, currencyFormat, currencySign, currencyBlank) if (currencyFormat == 4) return (formatNumber(price, priceDisplayPrecision, ',', '.') + blank + currencySign); if (currencyFormat == 5) - return (formatNumber(price, priceDisplayPrecision, ' ', '.') + blank + currencySign); + return (currencySign + blank + formatNumber(price, priceDisplayPrecision, '\'', '.')); return price; } diff --git a/themes/default/mobile/order-detail.tpl b/themes/default/mobile/order-detail.tpl index feaf3fee9..c51274600 100644 --- a/themes/default/mobile/order-detail.tpl +++ b/themes/default/mobile/order-detail.tpl @@ -51,7 +51,7 @@ {if $invoice AND $invoiceAllowed}
  • - {l s='Download your invoice as a PDF file.'}
  • + {l s='Download your invoice as a PDF file.'} {/if} {if $order->recyclable}