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.

5
votes
2answers
176 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\...
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
3k views

Magento 1.9 How to add buy now button in product page?

I am using magento 1.9, I want to add BUY NOW button on product details page, Buy now button redirect to checkout page. I tried many solution already solved in this forum, But all the solutions are ...
8
votes
1answer
12k views

Magento2 - How to add a product into cart programatically when checkout_cart_product_add_after is fired

Consider there are two product ie: Product A and Product B. Product B is a virual product which i need to add to cart when Product A is added to it. To do so, I am trying to add Product B to cart by ...
10
votes
4answers
15k views

How to enable AJAX for the the 'Add to Cart' button of product widgets in Magento 2?

In Magento 2 the normal Add to Cart button has a very nice AJAX-based logic to add products to the cart. However, when we use a Catalog Products List widget for example in CMS pages the button in this ...
6
votes
2answers
5k views

How to add Qty in add to cart form on Product Listings Page in Magento 2

How can you add a Qty filed to the the add to cart form on the category listings page. With the Luma theme the user only has the option to add one product to cart at a time from the product listings ...
9
votes
2answers
11k views

Magento2 - How to stop a product from getting added to cart programmatically?

What I want to do is if my custom attribute is set in quote then i do not want any product to be added in cart. My custom attribute is being set correctly. To stop product from getting added to cart,...
5
votes
2answers
4k views

How to add “Buy Now” button in Magento 2.1? [closed]

I need help to add "Buy Now" button on the product detail page. Thanks.
4
votes
4answers
20k views

Add to cart for out of stock products

I'm trying to get the Add to cart button to appear on products that are Out of stock. I've already set the System->Configuration->Catalog->Inventory->Backorders=Allow Qty Below 0 My store previously ...
1
vote
0answers
574 views

Configurable not adding to cart in magento2.1.9

I am trying to add configurable product programatically in cart i can add simple product to cart but while adding configurable product it showing "you must select product option to add cart" error in ...
9
votes
2answers
7k views

How to “add to cart” a product with custom input field and save it to Database?

I had created a custom module in which I am overriding the add to cart form on the product page, and I successfully did it with catalog_product_view.xml file. Now I can see a custom input field on the ...
2
votes
2answers
11k views

I want to use ADD TO CART via URL in Magento 1.8 but don't know which files to change

I have seen some suggested changes to make to call the FORM KEY to allow the ADD TO CART FROM URL to work. <?php $formKey = Mage::getSingleton('core/session')->getFormKey();?> <form ...
1
vote
2answers
6k views

Magento 2: How to get add to cart url in custom templete file and add product to cart

i am not able to get add to cart url in my custom template files , here is my code $postDataHelper = $this->helper('Magento\Framework\Data\Helper\PostHelper'); $postData = $postDataHelper->...
3
votes
1answer
317 views

How to find Customer cart overall weight?

How can I find customer cart overall weight?
3
votes
3answers
5k views

Replacement of an abstract class in custom module

I read a lot of information on this issue, but have not found a solution. I need to change the function getAddToCartUrl, in class Mage_Catalog_Block_Product_Abstract. Is there a way to make a ...
2
votes
1answer
9k views

Magento 2 programatically add product to cart? [duplicate]

We have a requirement that we wants to add product to cart programmatically in magento2.
2
votes
1answer
2k views

Add to cart configurable product programatically magento2

I tried with add to cart configurable product but getting error when run the custom code using observer but same code when run from controller than it's working fine. you can see below code for bundle ...
12
votes
7answers
8k views

Changing “Add to cart” button text in Magento 2.1.0 ( Overriding js file )

I have changed "Add to cart" text to "I want this" by overriding "vendor\magento\module-catalog\view\frontend\templates\product\list.phtml". But, when I click on "I want this" (i.e. "Add to cart" ) ...
7
votes
2answers
5k views

Adding product to cart cause error 'The stock item for Product is not valid.'?

I'm adding a nominal product programically to the shopping cart. But it throws an exception as 'The stock item for Product is not valid.'. How can I resolve this? NOTE : $product is getting passed to ...
5
votes
2answers
895 views

How to exclude products being added to cart based on products attributes?

How can i set a condition, if pre-ordered products are purchased, no other products can be added to cart? How can I set a condition like, if some of the "non-pre-order" products is in the cart, ...
3
votes
3answers
4k views

Magento2 how to add configurable product to cart programmatically [duplicate]

Magento2 how to add the configurable product to cart programmatically. I searched but found question related to how add simple product mostly.
6
votes
1answer
7k views

Ajax add to cart button in product detail page magento 2

I have check online demo of Magento 2 http://magento2-demo.nexcess.net/fusion-backpack.htmlwhen we click on add to cart it add product via AJAX but i have Set up demo on localhost it don't to add ...
2
votes
3answers
3k views

Magento 2: How I can add Configurable products to cart from category view with selected options

Currently simple products added to cart works from category view. I want same it for configurable products with selected options should be add to cart from category view page. Currently when I select ...
1
vote
1answer
2k views

How to retrieve product add to cart url in phtml file

I'm looking to add 5 products add to cart buttons to a CMS page in Magento 2, the code example I found online is: $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $listBlock = $...
1
vote
1answer
129 views

How to display Name, Thumbnail Image, Price, Add-to-cart Button On CMS PAGE?

I need to display all my products like, Sku Name Price Thumbnail Add-to-cart(Button) How can i get all above details on CMS Page? Note : Add-To-Cart Error
5
votes
1answer
1k views

Adding products to cart programmatically with custom price in controller: Magento 2

I am having a module that is creating quotes using the Magento quote module. It is using the \Magento\Quote\Model\QuoteFactory for creating the quotes. Now I have added a button "Proceed to ...
4
votes
4answers
9k views

Add product to cart programmatically invalid request for adding product to quote

I'm trying to create a controller to add to cart a product programmatically in magento 1.9, like this: <?php class Namespace_Module_IndexController extends Mage_Core_Controller_Front_Action{ ...
3
votes
2answers
321 views

Create new row in Database when we click on button

By Default Magento create new row in Database in table sales_flat_quote_item_option once we click on ADD TO CART We are giving an option of uploading custom image on Product image with help of ...
2
votes
4answers
4k views

Error when adding to cart 'No such entity with id = 0'

When I add a product to my cart I get the following error: No such entity with id = 0 This happens with every product in the store, can anyone help point me in the right direction?
2
votes
2answers
6k views

How to create and add `buy now` button along with add to cart button on each products?

I am new to magento,using Magento 1.9. with custom theme.I succesfully created buy now button on addtocart.phtml by the following codes <button type=”button” title=”Buy Now” class=”button btn-cart”...
2
votes
1answer
432 views

Magento Buy Now Button for Configurable Products

I Need Add a Buy Now Button For Direct Checkout. I Have Coded But Not Working For Configurable Products. If There Are Any Extension For That Please Suggest Me.
1
vote
2answers
169 views

I want to refresh the page automatically if users clicks on CHECK button

I want to refresh the product page automatically if the user clicks on "CHECK" button of zipcode field. I want to refresh the page automatically every time user click on CHECK button of zipcode or ...
1
vote
1answer
1k views

Magento 2 Customers can't login and add product to cart

The customers can't login, Magento return a 302 found response The admin can login without problems. And I can't add products to cart, Magento returns a 302 found response. I already do: Clean ...
0
votes
0answers
148 views

Magento 2.2.3 CE unable to add/remove item from wishlist?

We are getting facing an error message when we add (or) remove item from wishlist in magento 2.2.3 CE can you please advise? ? we didn't write any custom code from custom module. Fatal error: ...
0
votes
3answers
2k views

Magento 2: Skipping Shopping Cart Page after Add to Cart

I'm using Magento 2 CE Version 2.1.0. I have Googled & also referred some StackOverflow Q&A. I have done the following things: app\code\Custom\Module\etc\frontend\events.xml <?xml ...
0
votes
1answer
1k views

Mini cart not show product when add product for first time Magento 2.1

I am using Ultimo Infortis theme. I am facing issue in adding product to mini cart. First time when i click on Add to Cart button, it do not show product in mini cart but on cart page it show added ...
0
votes
1answer
4k views

Related Products template customize

How do you change the related products template output. Instead select all I would like to add a "add to cart" button to all related products and remove checkboxes.
5
votes
2answers
15k views

Check Some Condition Before Product added to cart

I want to add product to cart. So when i click on the add to cart button i will be checking some condition like some variable is set or not. If it is set, product will be added to cart. If not set, ...
6
votes
1answer
3k views

Remove success message after show

I custom add to cart module on Magento 2 and keep message like Magento core. if (!$this->_checkoutSession->getNoCartRedirect(true)) { if (!$this->cart->getQuote()->getHasError()) { ...
4
votes
3answers
4k views

What is step by step process for add products to magento guest cart using Rest apis?

I am trying like this, Step 1: Post(empty) baseurl/rest/V1/guest-carts get: guest customerid =02ccea0d67a4be667fa6ebf7905tia21 Step 2: I want add items to cart,so am using this api, POST /V1/guest-...
15
votes
2answers
3k views

Why is CSRF protection needed for add-to-cart?

Magento has since recent versions a form_key as part of the add to cart action, to protect against I think CSRF attacks. So now I wonder, is it really needed for this place, and why or better said, ...
8
votes
1answer
7k views

Magento2 redirecting to Shopping cart

Is there a way in Magento2 to have the user get redirected to shopping cart page after clicking "add to cart" - instead of the mini cart option at top of page?
4
votes
2answers
8k views

“Please specify the product's option(s).” after magento upgrade 1.6.2 to 1.9.1

I just upgraded a site from 1.6.2 to 1.9.1 I have a big issue with configurable products. Impossible to add them to the cart. I always get "Please specify the product's option(s)." There is no error ...
2
votes
1answer
891 views

Magento2 - Ajax Add to Cart - Out of stock situation - Stop redirect and show message dynamically

I have implemented Ajax to my "Add to Cart" button so that customers can add products to their cart without reloading the page. Here is bare minimum of code which I used in order to achieve ...
15
votes
4answers
4k views

Adding multiple items with different attributes to cart programmatically

I'm making a bulk add to cart system. Please note : i want it to works for simple products with with custom options -> Where custom option are like color(red , green , blue) or Size(Xl, M , S) ...
4
votes
1answer
1k views

Magento 2: How to update mini cart after add product to cart from API?

I'm working on a task that need an API endpoint for adding product to cart in Magento 2. My code do the job "add product to cart" properly (it add product to cart and when I go to .../checkout/cart I ...
4
votes
1answer
1k views

add to cart button in CMS page

In Magento2.1, I'm able to load a product in CMS page using: $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $product = $objectManager->get('Magento\Catalog\Model\Product')-&...
3
votes
2answers
3k views

I want to set custom price programmatically to the product Magento 2

I want to set the custom price for the product programmatically.In my current code , the customer create programmatically and set the products to the newly created customer.But i want set all product ...
2
votes
2answers
2k views

Making non-customisable bundles in Magento 2

I am trying to remove the options from bundles (in Magento 2), so that Bundle Items can be added straight to the Cart without users being able to customise these options. I thought the easiest way to ...
1
vote
2answers
1k views

Unable to add product in cart with custom option via querystring

I am trying to add products with custom options in cart via query string but it does not worked. //my redirecting on click here <?php echo "http://localhost/magento_bnsb_guide/index.php/checkout/...