Hot answers tagged

3

A few things here: Your opening tag is only <? instead of <?php Magento recommends against injecting sessions into your constructors You should not make a session available in a template. Whatever you need from the session should be wrapped up in block logic Magento provides a cart helper class which provides both cart and quote. Rather than accessing ...


3

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 cart item price. sales_quote_item_qty_set_after event provide quote item as it parameter.So you don't need to inject cart object $this->cart here. Also, ...


2

By default, Magento 2 in API side does not provide any API for Merge guest cart with customer card when the customer is login. But you can replace the guest cart with customer cart. API : (/V1/carts/:cartId) File : vendor/magento/module-quote/Model/QuoteManagement.php Function : public function assignCustomer($cartId, $customerId, $storeId) But if you ...


2

You need cart helper for this. add this code protected $cartHelper; public function __construct( ... \Magento\Checkout\Helper\Cart $cartHelper ... ) { ... $this->cartHelper = $cartHelper; ... } After this you can get items and product prices from this code: Before your loop you can get product prices against items $...


2

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 quote has been created by an admin. The effect of this is in the locations you stated that an admin can for example create an order for an item that normally would be out of ...


1

I think I've found a solution. Update your index.phtml file with below code $quote = $block->getCheckoutSession()->getQuote(); $items = $quote->getAllVisibleItems(); foreach($items as $item) { echo 'ID: '.$item->getProductId().'<br />'; echo 'Name: '.$item->getName().'<br />'; echo 'Sku: '.$...


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