The Stack Overflow podcast is back! Listen to an interview with our new CEO.

New answers tagged

0

This behavior (an event, di happens for one area and not the other) seems to be related to the area. I'm guessing that you have declared the event to the frontend area etc/frontend/events.xml. You should add that event the "global" area etc/events.xml


0

You Just need to update your add to cart action into your controller file. Move your below code $cart->save(); After completed your Foreach loop. It's working for me.


1

you have to change your code in observer file public function execute(Observer $observer) { $item = $observer->getEvent()->getData('quote_item'); $item = ( $item->getParentItem() ? $item->getParentItem() : $item ); $_product = $item->getProduct(); $options = $_product->getTypeInstance(true)...


1

You can override getValue() function in this js in your module vendor/magento/module-tax/view/frontend/web/js/view/checkout/summary/subtotal.js In your custom module you can override that function as below... app/code/MageHelper/ShippingDiscount/registration.php <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\...


0

use the session to get the quote and your cart items. use Magento\Checkout\Model\Session; public function __construct( ... Session $session ... ) { ... $this->_session = $session; ... } public function yourFunction() { $items = $this->_session->getQuote()->getAllVisibleItems(); ...


1

Finally I got an Answer... it will always return an empty array if I want to get the data in Homepage or any other page except cart page so the solution is we make to cacheable=false is layout like in my case my layout was Vender/Module/view/frontend/layout/default.xml <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-...


0

Your Block public function getQuoteData() { $this->_checkoutSession->getQuote(); if (!$this->hasData('quote')) { $this->setData('quote', $this->_checkoutSession->getQuote()); } return $this->_getData('quote'); } Call the Block in your template // Get all visible items in cart $...


0

This code will allow you to get all items of cart. $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $cart = $objectManager->get('\Magento\Checkout\Model\Cart'); // get quote items collection $itemsCollection = $cart->getQuote()->getItemsCollection(); // get array of all items what can be display directly $itemsVisible = $...


1

Magento does this automatically. You can adjust the cookie lifetime in the backend, which will determine how long the cart is stored - I think default is 1 hour, you can set it to 2 weeks or what you like. When the user deletes their cookies, though, there's no way to have him keep cart items without a customer account. This is because the PHP session has, ...


0

The attributes ts_dimensions_length / ts_dimensions_width / ts_dimensions_height are part of the Temando_Shipping module that ships with Magento 2. [ Source: Line 32 - 34 in vendor/temando/module-shipping-m2/Setup/SetupData.php ] You should be able to get their values by using the code snippet below: $product->getTsDimensionsLength(); $product->...


0

Its a little unclear if you are after the country code as you suggested or the currency code as the example you have highlighted uses. To get the current store currency code you can use \Magento\Store\Model\StoreManagerInterface. E.g in the scope of a block: $this->_storeManager->getStore()->getCurrentCurrencyCode() To get the current store ...


1

You need to do code like this one. $qty = 1; $quote = $this->quoteFactory->create()->load($quote->getId()); $product = $this->productRepository->getById($product->getId()); $magentooptions = array(5=>"1",23=>"2",32=>"3"); $par = array('product' => $product->getId(), 'bundle_options' => array(1 => $...


0

Fixed this. Used a javascript file to just pull and using find function to grab the cart counter number. Then just use show and hide on the content that on want to display dependant on whether the counter is greater than 0 or not.


0

Maybe issue is in the XML file, please replace this file. Path: view/frontend/layout/checkout_cart_sidebar_item_renderers.xml as: <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="minicart"> ...


0

you were called your my-template.phtml in default.xml...instead of this...call you phtml below the widget in cms page as below code {{block class="BDK\Mycartblock\Block\ShoppingCart" Template="BDK_Mycartblock::my-template.phtml"}}


0

Here is JS script I've written for similar task. The main idea here is a post request with changed item data you have to send to default endpoint in Magento(see getServiceUrl() method). It works for sure for registered customers, please don't forget check guest customers. Put code below into Vendor_Module/view/frontend/web/js/cart/options.js and replace &...


4

bccomp() function belongs to BCMath package; if it's undefined, then possible this library not installed or it's not enabled for your PHP version. Like for php7.2 need to install for ubuntu distribution: sudo apt install php7.2-bcmath


0

You may listen to catalog_product_save_after event and start comparing the new and old value to trigger an email sending event. Magento 2 seems to have native feature for product alerts.


0

You need to elaborate your question to get proper answer. Like - What kind of Operation do you want to perform and when you need to perform after product price updated from the backend? One such example - If you want to update the product price of the item added to the cart then you should use Object Manager: $cart = $objectManager->get('\Magento\...


2

You can follow below solution to achieve this. Vendor\Module\etc\extension_attributes.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd"> <extension_attributes for="Magento\Quote\Api\Data\CartItemInterface"> ...


Top 50 recent answers are included