From d9601ec63cd2343672bd6afc2113571907242a11 Mon Sep 17 00:00:00 2001 From: Olexandr Lysenko Date: Thu, 18 Dec 2014 16:57:53 +0200 Subject: [PATCH 001/149] MAGETWO-30913: Error when trying to apply coupon code in backend reorder after unchecking the discount apply checkbox --- .../Controller/Adminhtml/Order/Create.php | 23 ++++++++++++++++--- .../SalesRule/Model/Quote/Discount.php | 2 ++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php index 066511dee95c4..3e9af224b3a3d 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php @@ -270,16 +270,33 @@ protected function _processActionData($action = null) if (isset($data) && isset($data['coupon']['code'])) { $couponCode = trim($data['coupon']['code']); } + if (!empty($couponCode)) { - if ($this->_getQuote()->getCouponCode() !== $couponCode) { + $isApplyDiscount = false; + foreach ($this->_getQuote()->getAllItems() as $item) { + if ($item->getIsApplyDiscount() === true) { + $isApplyDiscount = true; + break; + } + } + if (!$isApplyDiscount) { $this->messageManager->addError( __( - '"%1" coupon code is not valid.', + '"%1" coupon code for item(s) selected do not apply discount', $this->_objectManager->get('Magento\Framework\Escaper')->escapeHtml($couponCode) ) ); } else { - $this->messageManager->addSuccess(__('The coupon code has been accepted.')); + if ($this->_getQuote()->getCouponCode() !== $couponCode) { + $this->messageManager->addError( + __( + '"%1" coupon code is not valid.', + $this->_objectManager->get('Magento\Framework\Escaper')->escapeHtml($couponCode) + ) + ); + } else { + $this->messageManager->addSuccess(__('The coupon code has been accepted.')); + } } } diff --git a/app/code/Magento/SalesRule/Model/Quote/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Discount.php index ac2b485eb9e8f..372a0db0c1229 100644 --- a/app/code/Magento/SalesRule/Model/Quote/Discount.php +++ b/app/code/Magento/SalesRule/Model/Quote/Discount.php @@ -87,6 +87,7 @@ public function collect(Address $address) foreach ($items as $item) { if ($item->getNoDiscount() || !$this->_calculator->canApplyDiscount($item)) { $item->setDiscountAmount(0); + $item->setIsApplyDiscount(false); $item->setBaseDiscountAmount(0); // ensure my children are zeroed out @@ -119,6 +120,7 @@ public function collect(Address $address) $this->_calculator->process($item); $this->_aggregateItemDiscount($item); } + $item->setIsApplyDiscount(true); } /** From 60584889a8bb9dff7f4d3b18a9fd6235e3a92029 Mon Sep 17 00:00:00 2001 From: Cari Spruiell Date: Thu, 18 Dec 2014 15:11:12 -0600 Subject: [PATCH 002/149] MAGETWO-31980: Remove backslash from use throughout the code base - removed leading backslashes from paths in 'use' statements --- .../Model/Product/Media/AttributeManagement.php | 6 +++--- .../templates/product/list/toolbar.phtml | 2 +- .../templates/product/list/toolbar/amount.phtml | 2 +- .../templates/product/list/toolbar/limiter.phtml | 2 +- .../templates/product/list/toolbar/sorter.phtml | 2 +- .../product/list/toolbar/viewmode.phtml | 2 +- .../Service/V1/PaymentMethod/ReadService.php | 5 ++--- .../Service/V1/Agreement/ReadService.php | 14 +++++++------- .../Model/OptionRepository.php | 16 ++++++++-------- .../catalog/product/edit/super/config.phtml | 2 +- .../Magento/Customer/Model/GroupManagement.php | 2 +- .../Magento/Sales/Model/Quote/Item/Processor.php | 10 +++++----- app/code/Magento/Sales/Model/QuoteRepository.php | 2 +- 13 files changed, 33 insertions(+), 34 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Product/Media/AttributeManagement.php b/app/code/Magento/Catalog/Model/Product/Media/AttributeManagement.php index 66d7eadb403ba..c161b01782266 100644 --- a/app/code/Magento/Catalog/Model/Product/Media/AttributeManagement.php +++ b/app/code/Magento/Catalog/Model/Product/Media/AttributeManagement.php @@ -4,9 +4,9 @@ */ namespace Magento\Catalog\Model\Product\Media; -use \Magento\Catalog\Api\ProductMediaAttributeManagementInterface; -use \Magento\Store\Model\StoreManagerInterface; -use \Magento\Catalog\Model\Product; +use Magento\Catalog\Api\ProductMediaAttributeManagementInterface; +use Magento\Store\Model\StoreManagerInterface; +use Magento\Catalog\Model\Product; class AttributeManagement implements ProductMediaAttributeManagementInterface { diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/list/toolbar.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/list/toolbar.phtml index 7fa828ff6b57e..9933823c685b3 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/list/toolbar.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/list/toolbar.phtml @@ -9,7 +9,7 @@ * * @var $this \Magento\Catalog\Block\Product\ProductList\Toolbar */ -use \Magento\Catalog\Model\Product\ProductList\Toolbar; +use Magento\Catalog\Model\Product\ProductList\Toolbar; ?> getCollection()->getSize()): ?>
diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/list/toolbar/amount.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/list/toolbar/amount.phtml index f2cbd86b6b3b3..6547e0f593951 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/list/toolbar/amount.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/list/toolbar/amount.phtml @@ -9,7 +9,7 @@ * * @var $this \Magento\Catalog\Block\Product\ProductList\Toolbar */ -use \Magento\Catalog\Model\Product\ProductList\Toolbar; +use Magento\Catalog\Model\Product\ProductList\Toolbar; ?>

getLastPageNum() > 1): ?> diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/list/toolbar/limiter.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/list/toolbar/limiter.phtml index 07df6bdce7db9..1d81a0e233701 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/list/toolbar/limiter.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/list/toolbar/limiter.phtml @@ -9,7 +9,7 @@ * * @var $this \Magento\Catalog\Block\Product\ProductList\Toolbar */ -use \Magento\Catalog\Model\Product\ProductList\Toolbar; +use Magento\Catalog\Model\Product\ProductList\Toolbar; ?>