Questions tagged [addtocart]

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

415 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
19
votes
1answer
8k views

Magento 2: Uncaught TypeError: Cannot read property '*' of undefined in (section-config.js:33)

It's duplicate question but I am facing the same issue while adding the product & removing items from the cart page. I have spent almost a day to resolve but no luck hope someone could help me ...
8
votes
0answers
312 views

Magento 2: Observer add product to cart?

I've read some other post about adding products to cart, but nothing seems to fit. I've an observer for checkout_cart_update_items_before that adds another product in same qty if specific product is ...
8
votes
0answers
587 views

Magento 2: How to make custom fee taxable

I want to add a tax on custom fee. tax calculation is perfect and gets tax amount but it's not set in TAX files in quote_address in the database. public function collect( \Magento\Quote\Model\...
7
votes
0answers
219 views

Magento2 Add to cart button in row with grouped products

In magento2 i want to add "Add to cart" button with qty for every single product of Grouped Product. Is it possible? How? I see that the form is only one. I also need to remove the standard "Add to ...
7
votes
1answer
3k views

Magento 2 Add to cart frontend event listener

I am trying to find good solution to execute custom javascript when product is successfully added to cart. Also this custom javascript need information about product that was added to cart (sku, qty, ...
6
votes
1answer
419 views

Different quantity for different size add to cart product

i've created configurable product which has different sizes and different colors, In my product details page currently there's only one quantity input field and i need to select the size before add to ...
6
votes
2answers
997 views

Product created programmatically unable to add to cart in magento 1.9.2?? It gives error “The product could not be found.”

public function createcustomerproduct($data) { Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); $product = Mage::getModel('catalog/product'); try { $...
5
votes
2answers
459 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\...
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 ...
5
votes
2answers
292 views

How to override class which extends Abstract Class

I want to override a class Magento\Catalog\Model\Product\Type\Simple di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
5
votes
1answer
1k views

Magento 1.9 :- Add to Cart Helper - not working

I've been trying to fix a problem on an inherited Magento 1.9.1 site - the problem is coming from a custom category page I think. The template is using the Add to Cart Helper - in what appears to be ...
4
votes
0answers
35 views

Unable to add multiple Products to cart in magento2

I have used below code in my controller. use Magento\Framework\Controller\ResultFactory; use Magento\Framework\App\Action\Action; use Magento\Framework\App\Action\Context; class Addtocart extends \...
4
votes
0answers
124 views

Removeing exist item during update items from cart : magento 2

I am doing some customization work on cart page. I want to add product multiple times with same configuration during update items. Add to cart is working good but existing items get removed during ...
4
votes
1answer
631 views

Bundle product: Add to cart instead of select option

I want to add add to cart on product detail page instead of select option, how can it be done? As of now it shows select option on product detail page , but i want add to cart button that will just ...
4
votes
1answer
1k views

Add multiple products to cart using Magento2 REST API using custom method

Add multiple products to cart using Magento2 REST API using custom method Their is no default magento api this is single product add to cart json code in rest api body section. { "cartItem": { ...
4
votes
1answer
1k views

Tracking Ajax Add to Cart Event

I have a problem I've been struggling for a couple of days and I would really like you to point me in the right direction. I am developing a module to track basic stuff like addToCart and ViewContent ...
3
votes
2answers
138 views

Magento 2. how to hide 'Add to cart button' using Plugins

How to Hide 'Add to cart' button using Plugins.I'm stuck in to hide add to cart button.
3
votes
2answers
81 views

custom option when product add to cart in magento 2.2.5

<?php namespace Ecomsolver\Measurement\Observer; use Magento\Framework\Event\ObserverInterface; use Magento\Framework\App\RequestInterface; class SetAdditionalOptions implements ...
3
votes
1answer
116 views

How to display swatch on cart page for added products in cart

How to display swatch on cart page for added products in cart. Right now it shows as Text, like Color Blue, but it should show like swatch icon.
3
votes
3answers
2k views

Magento 2: Add multiple products to cart programmatically

Following is the event observer for adding multiple products into cart: <?php namespace Namespace\Module\Observer; class ThirdPartyAdd implements \Magento\Framework\Event\ObserverInterface { ...
3
votes
1answer
93 views

Magento 1 : How to disable product price update on the front-end when changing a product Qty

I want to disable the price update with qty. In default magento price calculation is "Product PriceXQty". I want to disable it and total price in the cart is product price only.
3
votes
2answers
1k views

Add to Cart button in Magento 2.1

I tried with button add to cart and it not working, app/code/Moo/Custom/view/product.phtml <?php $product = $this->getData('product'); $postDataHelper = $this->helper('Magento\Framework\...
3
votes
0answers
229 views

Magento 2 - Add To Cart Button Direct To Product Details With Non Required Options

I am on Magento 2.1.1 and I am trying to change the Add to Cart button behaviour in Grid / List Views. At the moment, the add to cart button only directs the customer to the product detail page if ...
3
votes
2answers
2k views

How to override cart\addcontroller in magento 2?

I want this function in \code \StwBuyXGetY \BuyXGetY \Controller\Checkout\Cart\Add.php(this is written in magento 1.9, I want to convert it into magento 2). But I cant add any new function in add ...
3
votes
0answers
75 views

adding an item to the shopping cart does not add the first time; it does add the second time

This has been happening for a long time - when I add an item to the shopping cart the first time - it does not add to cart! The second time it does add... My Magento version is Magento 1.9.1.0 This ...
3
votes
0answers
1k views

Is there any way that one swatch is selected by default (magento configurable swatches)

I am trying use Magento Configurable swatches in my website (for colors). But I am facing some issues, in Product details page, we have to select one color swatch. In Product Listing Page, we are ...
3
votes
1answer
212 views

SOAP API to build cart for frontend - should I be worried? session collision or cart loss?

My developer has written PHP code on his CMS that connects via SOAP on behalf of the user browsing the site, to manage the cart from their CMS. I'm worried about the interaction of SOAP session (...
2
votes
0answers
19 views

Magento 2 - Add to cart not working after products loaded by ajax

I have loaded products collection using ajax. My controller URL is something like this: www.example.com/whoboughtthisproduct/index/getproducts Now products are loading properly, but when user click ...
2
votes
1answer
38 views

If script is includeed from default_head_blocks.xml error is noticed

I am developing a site in magento 2.3 flurys.digifrizz.com If script is included through default_head_blocks.xml there are lots of require js error noticed <page xmlns:xsi="http://www.w3.org/2001/...
2
votes
1answer
46 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" ...
2
votes
1answer
142 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\...
2
votes
2answers
170 views

How to restrict customer only to add products in cart Magento 2?

I need to integrate a functionality where when a user clicks add to cart it should check whether he is a logged in customer or not. If he is a logged in customer the product should be added in cart. ...
2
votes
0answers
27 views

create order on admin panel

How i can create one order from simple product if i just have simple product Sku ? or may by should i asked solution for save quote item on Frontend and create order on admin panel . i guess i ...
2
votes
0answers
80 views

Why the total product price in the shopping cart does not include the different product options selected?

Here is the issue that happened since my Magento installation has been restored. The shopping cart should normally include all the product options selected but since the restoration, only the product ...
2
votes
0answers
17 views

Magento 2.2.4 - unable to print messages. - New Theme

I have a Module which processes a Post action, and then redirects. for example i am trying to overwrite - Magento\Checkout\Controller\Cart\Add I have used my construct function and my method as ...
2
votes
0answers
211 views

Magento 1.9 : Add value to file type custom option when adding product to cart programmatically

I am calling $cart->addProduct($product, $params); for adding product to cart. Where, $product is product collection & $params is as follows as received from product page. Array ( [...
2
votes
0answers
206 views

Magento2.2.x Custom page side bar in display mini cart items

My custom page in displaying all product with add to cart product functionalities I want display mini cart items on page sidebar. after add to cart item update and display in that sections. like that....
2
votes
0answers
110 views

Magento 2 without user login add to cart ajax not working with redis session

I have Issue with Magento version. 2.2.0 with integration of redis session. In my magento 2.2.0 Redis Session is enabled , Now when user is not logged in(Guest User) to the system and try to add the ...
2
votes
0answers
118 views

Magento-2 update product custom option value in custom add to cart process

I want to update custom option value in add to cart. After add to cart i want to change product custom option value for perticular customer.
2
votes
2answers
878 views

Magento 2 : Add product to cart programmatically does not populate quote item id in validate method

How to add product to cart programmatically in Magento 2.2.0 ? I have tried below code but when I do not get Quote item id in Validate method of below file. \Magento\AdvancedSalesRule\Model\Rule\...
2
votes
1answer
1k views

Magento 2 add to cart button not showing for any product

On my magento website, add to cart button is not showing on any product page. I have checked inventory, visibility settings everything is correct still its not showing. can anyone please help ...
2
votes
0answers
578 views

The element 'product.info.options' already has a child with alias 'text' - Magento 2.2.0

After data migration (1.9.1 CE - 2.2.0 CE) I got the below error when I click add to cart button in magento 2 we can't add this item to your shopping cart right now I did research about this but ...
2
votes
0answers
381 views

Add a quote instance to cart: Magento 2

I am working on a custom module that is creating quotes using the Magento quote module. It is using the \Magento\Quote\Model\QuoteFactory for creating the quotes. Now I want to checkout the items ...
2
votes
0answers
170 views

AddToCart using GET and Query String in Magento 2.2

I am currently migrating a store from Magento 1.7 to Magento 2.2 On many of our product pages there is a button to order a free sample which is achieved by adding a product 'free sample' with options ...
2
votes
1answer
677 views

Magento 2: How to move the tier price table under the quantity input box on product view page

I am working on the product catalog page using my customized theme. Is it possible to insert my customized tier_prices.phtml inside my customized addtocart.phtml file? I need to put my tier prices ...
2
votes
0answers
243 views

Add product to cart programatically is not setting price when we add product at first time

When adding product first time to the cart is not setting the product price, But when we add another product to the same cart (second time) the price of both product is set. my code is below: public ...
2
votes
0answers
1k views

Shopping cart always “empty” after 1.9.3.4 upgrade

I have upgraded magento to 1.9.3.4 via magento connect from 1.9.3.3 and now whenever I try to add a product to the cart it says shopping cart empty. I added <?php echo $this->getBlockHtml('...
2
votes
2answers
173 views

Only allow sku to be added if other product exists in cart

I have a sku, let's call it sku100 for now. I only want that sku to be allowed to be added to cart if any other sku exists in the cart. I tried looking at shopping cart price rules but can't find any ...
2
votes
1answer
1k views

Magento2 - Add Custom Column in cart item table and insert data to custom column when product add to cart

i have added new column in 'quote_item' table. i want to add the data to custom column when user add any product to cart.
2
votes
0answers
45 views

Customise “add to cart” button

I want to edit the standard "add to cart" button to a "CLICK TO BUY" button. So that, once clicked will link through to the same product on another store (same magento install). Store 1 is a trade ...