Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [addtocart]

Questions related to the functionality of adding product to shopping cart in Magento.

0
votes
1answer
15 views

Magento 2 - Don't want to remove wishlist items when click 'Add all to cart' button

I want to keep items in wishlist when user click "add all to cart" button. Have any idea how to fix it?
0
votes
1answer
24 views

How to add custom option price when product is adding add to cart using controller

I have to add the custom option price when product is adding add to cart using controller
0
votes
0answers
12 views

Magento 2 - addToCart doesn't calculate price correctly

I am adding a product with custom options to my cart. One of the options costs extra. But the Magento Cart page does not show the price correctly. Here you can see the cart page. The Summary shows ...
1
vote
1answer
18 views

Add existing custom option to cart item if the option was not included initially

I can update existing cart values: $item = $quote->getItemById($itemId); $item->getOptionByCode('option_code')->setValue($value); $item->saveItemOptions(); But this only works if the ...
0
votes
0answers
13 views

Add Free Product to Cart price threshold doesn't work after discount applied

Were using Magento 1.9 CE We offer free gifts with purchase (GWP) when the GWP conditions are met. Most often the threshold is a certain $ amount. We have an issue that when a discount code is ...
0
votes
1answer
16 views

Call to a member function getValue() on null in AbstractType when loading cart

I have a simple product with a configuration option. The SKU of my product is configurator and the SKU of the options is configuration. The configuration option is a string field. To add the product ...
1
vote
0answers
20 views

How to debug checkout_cart_product_add_after event on exit

I am trying to exit point on observer for checkout_cart_product_add_after event. But it always refresh after item added to cart. Any way to print data when debug this event and not refresh the page. ...
0
votes
2answers
34 views

Custom price in cart not working in Magento 2.3.1 observer

I am developing a magento site for furniture sale. I have some grouped products. If a customer add 1 piece of any product of the group to cart, the special price will be added to cart. If the ...
0
votes
2answers
13 views

add item to cart with addition option console error Unable to unserialize value

i am trying to add product to cart with addition option but i ended up with message: "Unable to unserialize value." this error on console resoponse on section refresh. Console I am using ...
5
votes
2answers
175 views

How to set custom tax price during add to cart in Magento 2

I am adding product to cart using ajax call. Here is my controller code. use Magento\Framework\Controller\ResultFactory; use Magento\Framework\App\Action\Action; use Magento\Framework\App\Action\...
0
votes
1answer
11 views

How to add product to customer cart in magento2 programmatically

Everything works well, but it adds for all by default, but I need it added for a specific customer, regardless of whether it’s active at the moment or not, I have a customer ID, but how can i add ...
1
vote
3answers
159 views

Quote id is empty when inserting multiple records into cart in magento2

I am adding product to cart from ajax by passing product id Here is my controller code. use Magento\Framework\Controller\ResultFactory; use Magento\Framework\App\Action\Action; use Magento\...
2
votes
1answer
33 views

How to concatenate the success message in magento 2 in cart?

I created a module to alter the cart message. app\code\Eight25media\Changemsg\etc\frontend\events.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ...
1
vote
2answers
26 views

Getting error when using $messageCollection->getLastAddedMessage()->getText(); in magento 2

I created a module to add available qty to cart when customer request more than available qty. below is my code set. app/code/E25media/MagentoCommunity/etc/frontend/di.xml <?xml version="1.0"?&...
1
vote
0answers
20 views

Add multiple products to cart using product ids

I am trying to add multiple products to my cart. I have product ids in the form of $productIds = implode(',', array_column($points, 'productId')); which gives me numeric product ids like this : 5330,...
1
vote
1answer
26 views

How to add available qty to cart when customer request more than available qty?

As asked in the question, Is there any possibility to add available qty(in stock) to the cart when customer requesting more than available qty. How magento behave with this situation? ex : I have 5 ...
0
votes
0answers
12 views

requested product doesn't exist rest api

I'm creating rest api to add product to cart, it works okay for some users and doesn't for others. what is reason for that? here is the code: $customer = null; $isGuest = true; $quote = ...
0
votes
1answer
43 views

Fatal Error: 'Uncaught Error: Call to a member function setCustomPrice() on boolean magento 2.3

Here i am trying to add product to the cart using customerId and productId without customer logged in, it's working fine but its not adding custom Price to that product,please guide me if you have ...
0
votes
1answer
28 views

Get Product info from afterAddProduct Plugin in magento 2

I have a custom functionality for add to cart in product detail page. Once button clicked, sending product id and adding product to the cart. Used below code to implement it. <input type="hidden"...
0
votes
0answers
26 views

How to add product to the cart with customer id and product id magento 2.3?

Actually while adding product to the cart with product id and customer id, i am facing one error "We found an invalid request for adding product to quote." If anyone have any idea please guide me. &...
0
votes
2answers
35 views

Remove add to cart on category product

I am trying to remove the add to cart and add to compare buttons from the category page. At present I have used the following code: <referenceBlock name="product.info.addtocart" remove="true" />...
1
vote
2answers
38 views

Magento 2 How to Disable Add to Cart Button for Out of Stock Products

Magento 2.3 I have a 3rd part software I use for stock management so dont need Mangeto to manage my stock. If I set the manage stock option to no then the add to cart button on the product page is ...
0
votes
0answers
22 views

Magento2 Rest API - How to add dynamic option to cart item during adding product to cart

I am getting issue with checkout_cart_product_add_after event. Actually I have created one method with this event which adding dynamic product option during product add. Below is by code: public ...
1
vote
0answers
46 views

Automatically adding the character * (asterisk) at the input box without doing anything

I'm working on the compatibility of our client site. Upon checking, I have noted that in the checkout, on the field Postnummer it is automatically adding the character * in the field without doing ...
0
votes
2answers
36 views

send custom product price to checkout on add to cart in magento2

I have a custom price in phtml which is shown in the product page.Now I want to send that price to checkout page on add to cart click in magento2 that custom price is coming in js variable and input ...
0
votes
0answers
28 views

Magento2: How to restrict add configuration more than three products in configurable product

Magento2: How to restrict add configuration more than three products in a configurable product. Actually, In my case configurations restricted for more than three products and I am unable to find ...
0
votes
0answers
30 views

How to move my custom container after add to cart button in magento 2

How to move custom container (product.info.extrahint) after add to cart button in product detail page in magento 2 catalog_product_view.xml <referenceContainer name="content"> <...
0
votes
1answer
32 views

Magnto 2 update the cart custom option value

Currently am using magento 2.2.5, while adding the product to the cart the custom options values are stored in the quote_item_option table correctly. while updating the custom options ...
0
votes
0answers
18 views

Problems with button cart, and register in Magento 2.3.1

I test my Magento on ubuntu 18.04, In localhost, and i push the button a test product and he send a msg like this Your Session Expire , ok i going to register and when finish the form and send the ...
0
votes
0answers
24 views

Add to cart button is not working properly in listing page in Magento 2

I am using Magento 2.3.0 In Product detail page when we click on Add to cart button then the text in the button is changing from "Adding" to "Added" and then finally it displays "Add to cart" again. ...
0
votes
1answer
37 views

how to add another add to cart button in product page in magento2

I want to add customize add to add button near add to cart button and on that click, the product should add in the cart in magento2 I have followed this link:magento 2 Adding one more Add to cart ...
0
votes
0answers
11 views

on add to cart click save custom option data in datbase and display it on cart page in magento2 [duplicate]

on add to cart click, I want to save the custom option in database I have created all the model and controller files now how to add to cart button in phtml file is my question that on click that add ...
0
votes
0answers
68 views

Exception: Warning: Cannot modify header information - headers already sent by in magento 2?

In below program i got an error like Exception: Warning: Cannot modify header information - headers already sent in magento 2.I am not understand where i am writing wrong code.please help on this. &...
0
votes
0answers
7 views
1
vote
1answer
67 views

Missing add to cart button on some items

We're experiencing a strange issue with our catalog, I'm scratching my head of where to start looking for... Here are the symptoms: Item X - doesn't have the "Add to Cart" Button. When I go to the ...
1
vote
2answers
71 views

Magento 2.3 - Add product to cart issue with store view

I have two stores with id 1 and 2. Am trying to add product programmatically using below code $params = array( 'form_key' => $this->_formkey->getFormKey(), 'product' =...
1
vote
0answers
9 views

Bulk add to cart function issue

I added multiple products in the cart using this below script. <script> require(['jquery'], function (jquery) { document.getElementById("add").addEventListener("click", function () {...
1
vote
0answers
51 views

Add multiple products in cart programatically magento 2

I am trying to add multiple products in cart programmatically. This below code is working properly but I need to set quantity dynamically. If quantity is not set that product to be skipped without ...
0
votes
0answers
10 views

how to pass product page selected value to cart in magento2 [duplicate]

I want to pass the product page custom value selected in product page to cart page in magento2 my all values are coming from the phtml page as you can see in the picture there are options to ...
1
vote
2answers
126 views

Cart & Checkout blank Magento 2.3 after trying to add product to cart

In Magento 2.3 I am attempting to add an item to cart, however the cart shows empty and if I 'proceed to checkout' the checkout page is blank with just the loading gif icon. If I go to 'checkout/cart'...
2
votes
1answer
32 views

How can I put this button 'add to card' above the product image?

How can I put this button above the product image?
1
vote
0answers
36 views

Before Clearing cart I want to show Popup for confirmation

I have added popup it show but not clearing item from cart just reloaded on same page. Please someone look in this. Below is the my script. <script type="text/javascript"> require([ '...
2
votes
1answer
61 views

Redirect issue after add to cart in magento2 custom controller

I am calling my custom controller for adding the product through the form action. Below is my controller file. <?php namespace {Vendor}\{Module}\Controller\Product; use Magento\...
3
votes
1answer
106 views

Adding products to cart programmatically, sets item's price to zero. First time Only

Certain products I have in my store have an attribute called setup_fee_sku. If the product has this attribute I grab the value (which is a sku) load it, and add it to the cart programatically. But ...
2
votes
0answers
41 views

Delete and add product again from cart in Magento 2

I have used below code to delete quote item from the cart and add it again in my controller $referenceProductId = $this->getRequest()->getPost('product_id') $customPrice = 100; $params = ...
3
votes
2answers
134 views

Allow only one qty of item into cart in Magento 2

I have created a custom controller in my module and calling via ajax to add the item to cart. Below is my controller code. <?php namespace {Vendor}\{Module}\Controller\Product; ...
1
vote
1answer
46 views

How to remove Add to cart warning message without size color selection?

I have to remove the You need to choose options for your item. on Add to cart button when I don't select any color or size. I don't want to show this as a global message. I found that Add to cart is ...
1
vote
0answers
53 views

How to see the guest-cart in the webpage

I successfully added a product with the api rest using and the access point '/rest/default/V1/guest-carts/:cart-id:/items'. Now, I need to show this guest-cart in the cart page of the client Any idea?...
1
vote
0answers
10 views

Magento 2 : Getting issue during added non-visible product to cart through observer?

For this, I use below event observer <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:...
0
votes
1answer
29 views

Button add to cart stays on adding… after i setParam('product', false)

I have a checkout_cart_product_add_after event that calls to a observer file in which i want to check a condition. If that condition is false i block the product from adding to the cart and want to ...