Skip to content

Commit

Permalink
Merge 1.7.7.x to develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Boubker BRIBRI committed Dec 3, 2020
2 parents d82e06f + bf85c2e commit cd7d97e
Show file tree
Hide file tree
Showing 87 changed files with 12,119 additions and 11,230 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
$('#tag_form').submit(function()
{
$('#select_right option').each(function(i){
$(this).attr("selected", "selected");
$(this).prop('selected', 'selected');
});
});
</script>
Expand Down
2 changes: 1 addition & 1 deletion admin-dev/themes/new-theme/js/fos_js_routes.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default {
orderPaymentFormAmountInput: '#order_payment_amount',
orderPaymentInvoiceSelect: '#order_payment_id_invoice',
viewOrderPaymentsBlock: '#view_order_payments_block',
viewOrderPaymentsAlert: '.js-view-order-payments-alert',
privateNoteToggleBtn: '.js-private-note-toggle-btn',
privateNoteBlock: '.js-private-note-block',
privateNoteInput: '#private_note_note',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default class OrderViewPageMessagesHandler {
}

$orderMessage.val(message);
$orderMessage.trigger('input');
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

import Router from '@components/router';
import OrderViewPageMap from '@pages/order/OrderViewPageMap';

const {$} = window;

export default class OrderPaymentsRefresher {
constructor() {
this.router = new Router();
}

refresh(orderId) {
$.ajax(this.router.generate('admin_orders_get_payments', {orderId}))
.then(
response => {
$(OrderViewPageMap.viewOrderPaymentsAlert).remove();
$(`${OrderViewPageMap.viewOrderPaymentsBlock} .card-body`).prepend(response);
},
response => {
if (response.responseJSON && response.responseJSON.message) {
$.growl.error({message: response.responseJSON.message});
}
}
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {EventEmitter} from '@components/event-emitter';
import OrderDiscountsRefresher from '@pages/order/view/order-discounts-refresher';
import OrderProductRenderer from '@pages/order/view/order-product-renderer';
import OrderPricesRefresher from '@pages/order/view/order-prices-refresher';
import OrderPaymentsRefresher from '@pages/order/view/order-payments-refresher';
import Router from '@components/router';
import OrderInvoicesRefresher from './order-invoices-refresher';
import OrderProductCancel from './order-product-cancel';
Expand All @@ -43,6 +44,7 @@ export default class OrderViewPage {
this.orderProductManager = new OrderProductManager();
this.orderProductRenderer = new OrderProductRenderer();
this.orderPricesRefresher = new OrderPricesRefresher();
this.orderPaymentsRefresher = new OrderPaymentsRefresher();
this.orderDocumentsRefresher = new OrderDocumentsRefresher();
this.orderInvoicesRefresher = new OrderInvoicesRefresher();
this.orderProductCancel = new OrderProductCancel();
Expand Down Expand Up @@ -89,6 +91,7 @@ export default class OrderViewPage {

this.orderProductRenderer.updateNumProducts(numProducts - 1);
this.orderPricesRefresher.refresh(event.orderId);
this.orderPaymentsRefresher.refresh(event.orderId);
this.orderDiscountsRefresher.refresh(event.orderId);
this.orderDocumentsRefresher.refresh(event.orderId);
});
Expand All @@ -115,6 +118,7 @@ export default class OrderViewPage {
this.orderProductRenderer.resetEditRow(event.orderDetailId);
this.orderPricesRefresher.refresh(event.orderId);
this.orderPricesRefresher.refreshProductPrices(event.orderId);
this.orderPaymentsRefresher.refresh(event.orderId);
this.orderDiscountsRefresher.refresh(event.orderId);
this.orderInvoicesRefresher.refresh(event.orderId);
this.orderDocumentsRefresher.refresh(event.orderId);
Expand Down Expand Up @@ -155,6 +159,7 @@ export default class OrderViewPage {
this.orderProductRenderer.resetAddRow();
this.orderPricesRefresher.refreshProductPrices(event.orderId);
this.orderPricesRefresher.refresh(event.orderId);
this.orderPaymentsRefresher.refresh(event.orderId);
this.orderDiscountsRefresher.refresh(event.orderId);
this.orderInvoicesRefresher.refresh(event.orderId);
this.orderDocumentsRefresher.refresh(event.orderId);
Expand Down
39 changes: 20 additions & 19 deletions classes/CartRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ public function checkValidity(Context $context, $alreadyInCart = false, $display
if (!CartRule::isFeatureActive()) {
return false;
}
$cart = new Cart($context->cart->id);

// All these checks are necessary when you add the cart rule the first time, so when it's not in cart yet
// However when it's in the cart and you are checking if the cart rule is still valid (when performing auto remove)
Expand All @@ -693,12 +694,12 @@ public function checkValidity(Context $context, $alreadyInCart = false, $display
}
}

if ($context->cart->id_customer) {
if ($cart->id_customer) {
$quantityUsed = Db::getInstance()->getValue('
SELECT count(*)
FROM `' . _DB_PREFIX_ . 'orders` o
LEFT JOIN `' . _DB_PREFIX_ . 'order_cart_rule` ocr ON o.`id_order` = ocr.`id_order`
WHERE o.`id_customer` = ' . $context->cart->id_customer . '
WHERE o.`id_customer` = ' . $cart->id_customer . '
AND ocr.`deleted` = 0
AND ocr.`id_cart_rule` = ' . (int) $this->id . '
AND ' . (int) Configuration::get('PS_OS_ERROR') . ' != o.`current_state`
Expand All @@ -719,45 +720,45 @@ public function checkValidity(Context $context, $alreadyInCart = false, $display
SELECT crg.id_cart_rule
FROM ' . _DB_PREFIX_ . 'cart_rule_group crg
WHERE crg.id_cart_rule = ' . (int) $this->id . '
AND crg.id_group ' . ($context->cart->id_customer ? 'IN (SELECT cg.id_group FROM ' . _DB_PREFIX_ . 'customer_group cg WHERE cg.id_customer = ' . (int) $context->cart->id_customer . ')' : '= ' . (int) Configuration::get('PS_UNIDENTIFIED_GROUP')));
AND crg.id_group ' . ($cart->id_customer ? 'IN (SELECT cg.id_group FROM ' . _DB_PREFIX_ . 'customer_group cg WHERE cg.id_customer = ' . (int) $cart->id_customer . ')' : '= ' . (int) Configuration::get('PS_UNIDENTIFIED_GROUP')));
if (!$id_cart_rule) {
return (!$display_error) ? false : $this->trans('You cannot use this voucher', [], 'Shop.Notifications.Error');
}
}

// Check if the customer delivery address is usable with the cart rule
if ($this->country_restriction) {
if (!$context->cart->id_address_delivery) {
if (!$cart->id_address_delivery) {
return (!$display_error) ? false : $this->trans('You must choose a delivery address before applying this voucher to your order', [], 'Shop.Notifications.Error');
}
$id_cart_rule = (int) Db::getInstance()->getValue('
SELECT crc.id_cart_rule
FROM ' . _DB_PREFIX_ . 'cart_rule_country crc
WHERE crc.id_cart_rule = ' . (int) $this->id . '
AND crc.id_country = (SELECT a.id_country FROM ' . _DB_PREFIX_ . 'address a WHERE a.id_address = ' . (int) $context->cart->id_address_delivery . ' LIMIT 1)');
AND crc.id_country = (SELECT a.id_country FROM ' . _DB_PREFIX_ . 'address a WHERE a.id_address = ' . (int) $cart->id_address_delivery . ' LIMIT 1)');
if (!$id_cart_rule) {
return (!$display_error) ? false : $this->trans('You cannot use this voucher in your country of delivery', [], 'Shop.Notifications.Error');
}
}

// Check if the carrier chosen by the customer is usable with the cart rule
if ($this->carrier_restriction && $check_carrier) {
if (!$context->cart->id_carrier) {
if (!$cart->id_carrier) {
return (!$display_error) ? false : $this->trans('You must choose a carrier before applying this voucher to your order', [], 'Shop.Notifications.Error');
}
$id_cart_rule = (int) Db::getInstance()->getValue('
SELECT crc.id_cart_rule
FROM ' . _DB_PREFIX_ . 'cart_rule_carrier crc
INNER JOIN ' . _DB_PREFIX_ . 'carrier c ON (c.id_reference = crc.id_carrier AND c.deleted = 0)
WHERE crc.id_cart_rule = ' . (int) $this->id . '
AND c.id_carrier = ' . (int) $context->cart->id_carrier);
AND c.id_carrier = ' . (int) $cart->id_carrier);
if (!$id_cart_rule) {
return (!$display_error) ? false : $this->trans('You cannot use this voucher with this carrier', [], 'Shop.Notifications.Error');
}
}

if ($this->reduction_exclude_special) {
$products = $context->cart->getProducts();
$products = $cart->getProducts();
$is_ok = false;
foreach ($products as $product) {
if (!$product['reduction_applies']) {
Expand Down Expand Up @@ -794,7 +795,7 @@ public function checkValidity(Context $context, $alreadyInCart = false, $display
}

// Check if the cart rule is only usable by a specific customer, and if the current customer is the right one
if ($this->id_customer && $context->cart->id_customer != $this->id_customer) {
if ($this->id_customer && $cart->id_customer != $this->id_customer) {
if (!Context::getContext()->customer->isLogged()) {
return (!$display_error) ? false : ($this->trans('You cannot use this voucher', [], 'Shop.Notifications.Error') . ' - ' . $this->trans('Please log in first', [], 'Shop.Notifications.Error'));
}
Expand All @@ -809,12 +810,12 @@ public function checkValidity(Context $context, $alreadyInCart = false, $display
$minimum_amount = Tools::convertPriceFull($minimum_amount, new Currency($this->minimum_amount_currency), Context::getContext()->currency);
}

$cartTotal = $context->cart->getOrderTotal($this->minimum_amount_tax, Cart::ONLY_PRODUCTS);
$cartTotal = $cart->getOrderTotal($this->minimum_amount_tax, Cart::ONLY_PRODUCTS);
if ($this->minimum_amount_shipping) {
$cartTotal += $context->cart->getOrderTotal($this->minimum_amount_tax, Cart::ONLY_SHIPPING);
$cartTotal += $cart->getOrderTotal($this->minimum_amount_tax, Cart::ONLY_SHIPPING);
}
$products = $context->cart->getProducts();
$cart_rules = $context->cart->getCartRules(CartRule::FILTER_ACTION_ALL, false);
$products = $cart->getProducts();
$cart_rules = $cart->getCartRules(CartRule::FILTER_ACTION_ALL, false);

foreach ($cart_rules as $cart_rule) {
if ($cart_rule['gift_product']) {
Expand All @@ -837,17 +838,17 @@ public function checkValidity(Context $context, $alreadyInCart = false, $display
- if there are products in the cart (gifts excluded)
Important note: this MUST be the last check, because if the tested cart rule has priority over a non combinable one in the cart, we will switch them
*/
$nb_products = Cart::getNbProducts($context->cart->id);
$nb_products = Cart::getNbProducts($cart->id);
$otherCartRules = [];
if ($check_carrier) {
$otherCartRules = $context->cart->getCartRules(CartRule::FILTER_ACTION_ALL, false);
$otherCartRules = $cart->getCartRules(CartRule::FILTER_ACTION_ALL, false);
}
if (count($otherCartRules)) {
foreach ($otherCartRules as $otherCartRule) {
if ($otherCartRule['id_cart_rule'] == $this->id && !$alreadyInCart) {
return (!$display_error) ? false : $this->trans('This voucher is already in your cart', [], 'Shop.Notifications.Error');
}
$giftProductQuantity = $context->cart->getProductQuantity($otherCartRule['gift_product'], $otherCartRule['gift_product_attribute']);
$giftProductQuantity = $cart->getProductQuantity($otherCartRule['gift_product'], $otherCartRule['gift_product_attribute']);

if ($otherCartRule['gift_product'] && !empty($giftProductQuantity['quantity'])) {
--$nb_products;
Expand All @@ -860,13 +861,13 @@ public function checkValidity(Context $context, $alreadyInCart = false, $display
WHERE (id_cart_rule_1 = ' . (int) $this->id . ' AND id_cart_rule_2 = ' . (int) $otherCartRule['id_cart_rule'] . ')
OR (id_cart_rule_2 = ' . (int) $this->id . ' AND id_cart_rule_1 = ' . (int) $otherCartRule['id_cart_rule'] . ')');
if (!$combinable) {
$cart_rule = new CartRule((int) $otherCartRule['id_cart_rule'], $context->cart->id_lang);
$cart_rule = new CartRule((int) $otherCartRule['id_cart_rule'], $cart->id_lang);
// The cart rules are not combinable and the cart rule currently in the cart has priority over the one tested
if ($cart_rule->priority <= $this->priority) {
return (!$display_error) ? false : $this->trans('This voucher is not combinable with an other voucher already in your cart: %s', [$cart_rule->name], 'Shop.Notifications.Error');
} else {
// But if the cart rule that is tested has priority over the one in the cart, we remove the one in the cart and keep this new one
$context->cart->removeCartRule($cart_rule->id);
$cart->removeCartRule($cart_rule->id);
}
}
}
Expand All @@ -884,7 +885,7 @@ public function checkValidity(Context $context, $alreadyInCart = false, $display
LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON ocr.`id_order` = o.`id_order`
WHERE ocr.`id_cart_rule` = ' . (int) $this->id . '
AND ocr.`deleted` = 1
AND o.`id_cart` = ' . $context->cart->id);
AND o.`id_cart` = ' . $cart->id);
if ($removed_order_cartRule_id) {
return (!$display_error) ? false : $this->trans('You cannot use this voucher because it has manually been removed.', [], 'Shop.Notifications.Error');
}
Expand Down
2 changes: 1 addition & 1 deletion classes/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class CustomerCore extends ObjectModel
'max_payment_days' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'copy_post' => false],
'active' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false],
'deleted' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false],
'note' => ['type' => self::TYPE_HTML, 'validate' => 'isCleanHtml', 'size' => 65000, 'copy_post' => false],
'note' => ['type' => self::TYPE_HTML, 'size' => 65000, 'copy_post' => false],
'is_guest' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false],
'id_shop' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false],
'id_shop_group' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false],
Expand Down
Loading

0 comments on commit cd7d97e

Please sign in to comment.