Closed philipvandebriel closed 7 years ago
I'm having the exactly same issue with 2.1
@wert2all Is there a temporary fix for it?
Hi, guys.
Thanks for reporting this, I've created ticket #MAGETWO-57354 in our internal Jira. This issue will be closed after fix.
Hi,
I experienced the same issue. And even worse, I will get a http 500 error when I add the 3rd item to the cart when the minimum order is enabled.
It is Magento 2.1. Bitnami package on AWS.
Thanks
Rex
For my ongoing project in Magento 2.1 I have done below things to come out from this problem,
1) Create Plugin
<type name="Magento\Quote\Model\Quote">
<plugin name="min-orderamount-skip-delete" type="Namespace\ModuleName\Model\QuoteAfter" sortOrder="10"/>
</type>
2) in QuoteAfter class
public function afterValidateMinimumAmount()
{
$actionName = $this->request->getActionName();
if($actionName === 'delete') {
return true;
}
}
This solved my problem and I got success to delete item.
magento 2.1.2 Problem with deleting, updating and adding to cart once an item is added to the cart
traced the problem to vendor/magento/module-quote/Model/ShippingAddressManagement.php#120
commented out that if and it all seams to work fine now.
Also InputException takes \Magento\Framework\Phrase for first param but in this class string is used, so 500 error.
I also got problems with minimum order amount, cannot delet item from cart anymore, but there is no error message, only blank page. I disabled minimum order amount, and everythin works fine. Any solution for this?
For the one who want it, I did a module, based on the solution of @ivankaranjac , which override the function of the original file : mediafire.com Put the "BugsFix" folder into "app/code". Note : tested on Magento 2.1.3
Still got that issue in 2.1.4, any updates on that?
Fatal error happens if sales/minimum_order/description is provided. This is because Magento\Quote\Model\Quote\Validator\MinimumOrderAmount\ValidationMessage::getMessage() returns just this string and not a Phrase object.
Closing as issue is fixed in the develop
branch with the linked commits.
Reopening, as 2.1
fix is not available yet.
Internal ticket to track issue progress: MAGETWO-69375
Internal ticket to track issue progress: MAGETWO-64899
Internal ticket to track issue progress: MAGETWO-71761
I've updated Magento to version 2.2 the problem is still there
Simply modify vendor/magento/module-quote/Model/ShippingAddressManagement.php to include the RequestInterface and check to see if the update_cart_action was posted, my code is below and seems to work fine tested on 2.1.8 and 2.2.0 RC3
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Quote\Model;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\InputException;
use Magento\Framework\Exception\NoSuchEntityException;
use Psr\Log\LoggerInterface as Logger;
/**
* Quote shipping address write service object.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ShippingAddressManagement implements \Magento\Quote\Model\ShippingAddressManagementInterface
{
/**
* Quote repository.
*
* @var \Magento\Quote\Api\CartRepositoryInterface
*/
protected $quoteRepository;
/**
* Logger.
*
* @var Logger
*/
protected $logger;
/**
* Validator.
*
* @var QuoteAddressValidator
*/
protected $addressValidator;
/**
* @var \Magento\Customer\Api\AddressRepositoryInterface
*/
protected $addressRepository;
/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
protected $scopeConfig;
/**
* @var Quote\TotalsCollector
*/
protected $totalsCollector;
/**
* @var \Magento\Quote\Model\Quote\Validator\MinimumOrderAmount\ValidationMessage
*/
private $minimumAmountErrorMessage;
/**
* @var \Magento\Framework\App\RequestInterface
*/
protected $requestInterface;
/**
* @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
* @param QuoteAddressValidator $addressValidator
* @param Logger $logger
* @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param Quote\TotalsCollector $totalsCollector
*
*/
public function __construct(
\Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
QuoteAddressValidator $addressValidator,
Logger $logger,
\Magento\Customer\Api\AddressRepositoryInterface $addressRepository,
\Magento\Framework\App\RequestInterface $requestInterface,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Quote\Model\Quote\TotalsCollector $totalsCollector
) {
$this->quoteRepository = $quoteRepository;
$this->addressValidator = $addressValidator;
$this->logger = $logger;
$this->addressRepository = $addressRepository;
$this->request = $requestInterface;
$this->scopeConfig = $scopeConfig;
$this->totalsCollector = $totalsCollector;
}
/**
* {@inheritDoc}
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function assign($cartId, \Magento\Quote\Api\Data\AddressInterface $address)
{
/** @var \Magento\Quote\Model\Quote $quote */
$quote = $this->quoteRepository->getActive($cartId);
if ($quote->isVirtual()) {
throw new NoSuchEntityException(
__('Cart contains virtual product(s) only. Shipping address is not applicable.')
);
}
$saveInAddressBook = $address->getSaveInAddressBook() ? 1 : 0;
$sameAsBilling = $address->getSameAsBilling() ? 1 : 0;
$customerAddressId = $address->getCustomerAddressId();
$this->addressValidator->validate($address);
$quote->setShippingAddress($address);
$address = $quote->getShippingAddress();
if ($customerAddressId === null) {
$address->setCustomerAddressId(null);
}
if ($customerAddressId) {
$addressData = $this->addressRepository->getById($customerAddressId);
$address = $quote->getShippingAddress()->importCustomerAddressData($addressData);
} elseif ($quote->getCustomerId()) {
$address->setEmail($quote->getCustomerEmail());
}
$address->setSameAsBilling($sameAsBilling);
$address->setSaveInAddressBook($saveInAddressBook);
$address->setCollectShippingRates(true);
$postData = $this->request->getParam('update_cart_action');
if(!$postData) {
if (!$quote->validateMinimumAmount($quote->getIsMultiShipping())) {
throw new InputException(__($this->getMinimumAmountErrorMessage()->getMessage()));
}
}
try {
$address->save();
} catch (\Exception $e) {
$this->logger->critical($e);
throw new InputException(__('Unable to save address. Please check input data.'));
}
return $quote->getShippingAddress()->getId();
}
/**
* {@inheritDoc}
*/
public function get($cartId)
{
/** @var \Magento\Quote\Model\Quote $quote */
$quote = $this->quoteRepository->getActive($cartId);
if ($quote->isVirtual()) {
throw new NoSuchEntityException(
__('Cart contains virtual product(s) only. Shipping address is not applicable.')
);
}
/** @var \Magento\Quote\Model\Quote\Address $address */
return $quote->getShippingAddress();
}
/**
* @return \Magento\Quote\Model\Quote\Validator\MinimumOrderAmount\ValidationMessage
* @deprecated
*/
private function getMinimumAmountErrorMessage()
{
if ($this->minimumAmountErrorMessage === null) {
$objectManager = ObjectManager::getInstance();
$this->minimumAmountErrorMessage = $objectManager->get(
\Magento\Quote\Model\Quote\Validator\MinimumOrderAmount\ValidationMessage::class
);
}
return $this->minimumAmountErrorMessage;
}
}
I am having the same issue with 2.1.10. To verify if this was fixed, I setup a clean Magento 2.1.12 instance, and the issue is still there. When I try to remove an item from the cart:
When updating the QTY:
The only way it updates is when the price x qty equals the minimum amount.
I commented line 120-122 (as mentioned also by @ivankaranjac ) to get this work:
if (!$quote->validateMinimumAmount($quote->getIsMultiShipping())) {
throw new InputException($this->getMinimumAmountErrorMessage()->getMessage());
}
EDIT: I tried @DavaGordon's solution but that fixes only cart update or clear cart. It does not fix deleting individual items in the cart, adding products from the category/product page, deleting or updating items from the minicart.
It doesn't look like this is fixed. Will you be re-opening it?
Bug still present in Magento 2.1.17.
Here is the error log:
PHP Fatal error: Uncaught TypeError: Argument 1 passed to Magento\\Framework\\Exception\\InputException::__construct() must be an instance of Magento\\Framework\\Phrase, string given, called in PATH/vendor/magento/module-quote/Model/ShippingAddressManagement.php on line 121 and defined in PATH/vendor/magento/framework/Exception/InputException.php:51, referer: https://www.elioworld.com/checkout/cart/
Stack trace:, referer: https://www.elioworld.com/checkout/cart/
#0 PATH/vendor/magento/module-quote/Model/ShippingAddressManagement.php(121): Magento\\Framework\\Exception\\InputException->__construct('Attenzione: l'o...'), referer: https://www.elioworld.com/checkout/cart/
#1 PATH/vendor/magento/module-quote/Model/Quote/ShippingAssignment/ShippingProcessor.php(66): Magento\\Quote\\Model\\ShippingAddressManagement->assign('22', Object(Magento\\Quote\\Model\\Quote\\Address)), referer: https://www.elioworld.com/checkout/cart/
#2 PATH/vendor/magento/module-quote/Model/Quote/ShippingAssignment/ShippingAssignmentProcessor.php(110): Magento\\Quote\\Model\\Quote\\ShippingAssignment\\ShippingProcessor->save(Object(Magento\\Quot in PATH/vendor/magento/framework/Exception/InputException.php on line 51, referer: https://www.elioworld.com/checkout/cart/
Preconditions
Update magento 2.0.8 to Magento 2.1 Debian Jessie Mysql 5.6 Php 5.6
Steps to reproduce
Expected result
Actual result
Recoverable Error: Argument 1 passed to Magento\Framework\Exception\InputException::__construct() must be an instance of Magento\Framework\Phrase, string given, called in /var/www/clients/client1/web1/web/vendor/magento/module-quote/Model/ShippingAddressManagement.php on line 121 and defined in /var/www/clients/client1/web1/web/vendor/magento/framework/Exception/InputException.php on line 51
If disable Minimum Order Amount then everything is fine.