Skip to main content
19 votes
Accepted

Magento 2 : Updating quote item

I am not sure about my below solution: May be you need to load Quote item object by item id As you want set price then using setPrice() you cannot set your desire price for that cart item $item = $...
Amit Bera's user avatar
  • 77.7k
15 votes

How to adding Custom Attributes to Magento 2 Quotes and Orders

app/code/Vendor/Module/etc/catalog_attributes.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:...
Oscprofessionals's user avatar
11 votes
Accepted

How to check if cart is empty in observer Magento 2

You can also use the cart helper protected $cartHelper; public function __construct( \Magento\Checkout\Helper\Cart $cartHelper ) { $this->cartHelper = $cartHelper; }...
Nikolas's user avatar
  • 2,291
11 votes
Accepted

Get quote item collection by using quote item id in Magento 2

private $quoteItemFactory; private $itemResourceModel; public function __construct( ..... \Magento\Quote\Model\Quote\ItemFactory $quoteItemFactory, \Magento\Quote\Model\ResourceModel\Quote\Item $...
Marius's user avatar
  • 199k
10 votes
Accepted

Magento 2 : How to Update cart after cart update event (checkout_cart_update_items_after)

I ended up using plugin di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:...
Vishwas Bhatnagar's user avatar
10 votes

How quotes and cart work in magento

A quote is cart object, this quote is created when the customer adds the first product to the cart and its not created when the customer is created. A customer can have many quotes. One for each ...
PЯINCƎ's user avatar
  • 11.7k
10 votes
Accepted

What does "setIsSuperMode" do on Quote Object in Magento 2?

Reference Link The quote is set into super mode in app/code/core/Mage/Adminhtml/Model/Session/Quote.php: $this->_quote->setIsSuperMode(true); Essentially it is a flag on the quote that this ...
Ronak Rathod's user avatar
  • 6,450
9 votes
Accepted

How to properly get current quote in Carrier Collect Rates function?

You can not directly get quote in collect rate. The $this->checkoutSession->getQuote() will call your collectRates function at the end, so you will end up getting infinite loop. the $request ...
Shoaib Munir's user avatar
  • 9,572
8 votes
Accepted

Magento 2 : Show cart items total to header cart link

You can display cart items sub-total to header minicart link. Add below code to minicart.phtml to display cart items total <span data-bind="html: getCartParam('subtotal')"></span> php ...
Suresh Chikani's user avatar
8 votes
Accepted

Will quote be removed after order created?

When the order is placed, the quote is deactivated. The field is_active is set to 0. There is a cron that removes all the inactive quotes that are older than X days. The cron is sales_clean_quotes and ...
Marius's user avatar
  • 199k
7 votes
Accepted

Update custom column data in quote table Magento 2

The easiest way to solve this is to fill in this field in the quote model and save it using the Repository: class QuoteUpdater { /** * @var \Magento\Quote\Model\QuoteRepository */ ...
Mageworx's user avatar
  • 3,566
7 votes

How to get the Quote Id from Masked Quote Id (QuoteIdMask) in magento 2

Since 2.3 version of Magento you can use the \Magento\Quote\Model\MaskedQuoteIdToQuoteIdInterface::execute(string $maskedQuoteId) to obtain a real quote id (int): <?php namespace Vendor\Module\...
Siarhey Uchukhlebau's user avatar
7 votes
Accepted

Magento 2 | Get number of items in cart

$helper = $this->helper('\Magento\Checkout\Helper\Cart'); echo $helper->getSummaryCount();
PЯINCƎ's user avatar
  • 11.7k
7 votes
Accepted

Magento 2 : how to convert custom quote field to order field

add the fields to both table quote and sales_order via a setup script in your module. Then add an event in your module (see below) <?xml version="1.0"?> <config xmlns:xsi=&...
Herve Tribouilloy's user avatar
6 votes
Accepted

Quote: getOrigOrderId vs. getReservedOrderId

The Magento\Quote\Model\Quote::getReservedOrderId() method is used when Order is placed and Quote is in the process of converting to a new Order. reserved_order_id then saved as new increment_id in ...
Max Pronko's user avatar
  • 1,775
6 votes
Accepted

Magento 2 - How to programmatically add a product to cart multiple times but with different options?

Somewhere in Magento 2 code is the answer : /** * We need to reload product in this place, because products * with the same id may have different sets of order attributes. */ It means that when I ...
DependencyHell's user avatar
6 votes

How to add custom option in quote or order item

You can achieve by a plugin in Magento 2.2.* First of all, we need to create an observer file and one Magento event file to implement this functionality. <?xml version="1.0"?> <config ...
shah dhairya's user avatar
5 votes
Accepted

Is there a valid reason two orders would have the same quote id?

From a clean Magento standpoint, no. Every order should only be related to one quote, and vice-versa. I know there are some modules out there that will use a single quote for multiple orders to ...
Brett's user avatar
  • 1,854
5 votes
Accepted

How to get the billing address from a quote instance: Magento 2

These error comes from a method public function getFormattedAddress(Address $address) because you expect to get the order address as a first argument. Try to remove the argument validation: public ...
Siarhey Uchukhlebau's user avatar
5 votes

Magento 2: Change quote from current quote to other quote id

Give a try $quote = $this->quoteRepository->get(**<Your_quote_id>**); $quote->setIsActive(1); $quoteRepository->save($quote); $this->checkoutSession->replaceQuote(...
Nikolas's user avatar
  • 2,291
5 votes
Accepted

What is the difference between order id, increment id and quote id?

The difference is: order_id is the internal Magento order ID (database table auto increment id) increment_id is the ID which you communicate to your customer quote_id is the internal quote id (...
Piyush's user avatar
  • 5,914
5 votes

Integrity constraint error referring to quote_item table while adding product to cart

I ran into the same problem when i tried to change data on quote items with the checkout_cart_product_add_after event. This event is fired after every product add, but before the cart is saved. Check ...
remklov's user avatar
  • 331
5 votes

Magento2 : Which Magento Event for Update cart quantity only?

Use sales_quote_item_qty_set_after which will fire when Qty is update. $this->_eventManager->dispatch('sales_quote_item_qty_set_after', ['item' => $this]); I guess that you want to update ...
Amit Bera's user avatar
  • 77.7k
4 votes
Accepted

Magento 2: How to add extra variable in session for Cart

Use the Below Code in your Custom Module to Set, Unset Session protected $_checkoutSession; public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\...
Brad Hodge's user avatar
4 votes

Event to check quote for product on every page

In order to add an observer to an event on every page add this in config.xml of your module. <events> <controller_action_predispatch> <observers> <...
Umar Yousaf's user avatar
4 votes

Quote trigger_recollect never passing to 0?

Yes, this is normal. trigger_recollect is used as a flag that is unset once the totals are recollected. This happens in the quote model's _afterLoad() method: //Code from Magento\Quote\Model\Quote ...
tjons's user avatar
  • 1,831
4 votes

magento2 get quote Id from customer

You can fetch quote data from quote table by customer id: public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Quote\Model\Quote $item, ...
Sameer Bhayani's user avatar
4 votes

collectTotals() on quote does not update configurable product item price

I have a little different type of issue with a configurable product. The total of configurable product counted double time. So I dig into code in Magento 2.2 and found that in Magento 2.2 they ...
Prince Patel's user avatar
  • 22.9k
4 votes
Accepted

Magento 2 : Fetch customer Id from quote object

You can get the customer Id as follows. $customerId = $quote->getCustomer()->getId();
Oshan's user avatar
  • 1,952
4 votes
Accepted

Get all item in cart using quote id Magento 2

I assume you want to get that in a class. If not, you should. Let's say the class name is Vendor\Module\Model\QuoteItems. It should look like this: <?php namespace Vendor\Module\Model; ...
Marius's user avatar
  • 199k

Only top scored, non community-wiki answers of a minimum length are eligible