Questions tagged [addtocart]

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

Filter by
Sorted by
Tagged with
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
2k 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
1answer
1k views

magento 2 Adding one more Add to cart button

How to add one more add to cart button in magento 2 product view page and working of 2 buttons are independently [not conflict one button to another button] and validations also must to add product to ...
2
votes
2answers
3k views

Magento2 catch ajax complete, add to cart

I'm building an custom mini-cart. I want it to update itself when an article is added to the cart. I'm trying to do this by jQuery with catching the ajax complete, but can't get it to work. Can anyone ...
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
3answers
2k views

Remove Add To Cart Button in product List page magento2 without using template file

I want to remove Add To Cart button at category page. but I don't want to use template file. I did it for product view page using event. $layout = $observer->getEvent()->getLayout(); $...
1
vote
0answers
68 views

How to do selected single product should be purchase alone?

I have one restricted product, here how to do selected single product should be purchased alone? No other products are eligible to add add-to-cart if this product available in the add-to-cart, same if ...
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/...
1
vote
1answer
3k views

Magento2 Change bundle item price in cart

I would like to change the price of the bundle product items after its has been added to cart and recalculate the bundle product price and changing the bundle item price. I was thinking of using the ...
1
vote
1answer
5k views

How to change product name in quote item dynamically

Is it possible to add several the same product times to the cart with a different name? I did with different price, but I have not managed to do it with a different name. I used an observer "...
1
vote
1answer
3k views

Bypass Magento's form key usage to allow simple product to be added to cart

Magento CE 1.9.0.1 Just upgraded from CE 1.7 and our links that we previously used to add products to cart no longer work. Examples: http://www.website.com/checkout/cart/add?product=215&qty=1 ...
1
vote
1answer
7k views

Replace “Add to Cart” button with an “Enquire” button linking to the “Contact Us” page

In both product listings (e.g. the category page) and the product view page, I need to replace the button "Add to Cart" with an "enquire" button which links to the "Contact Us" page. Please help me ...
0
votes
1answer
2k views

Magento 2 : How to Add Google Analytics when Item Added to Minicart

I want to track google analytics when user add item to minicart. I noticed that it make an ajax call to customer/section/load. So I want to add my google analytics code when these ajax success. ...
5
votes
6answers
4k views

I am trying to add link to the success message in Magento 2

I am trying to add a product details link in the success message after a user clicks the add to cart button. So I create a variable in my controller but and want to send cart link. Here is file ...
4
votes
2answers
2k views

Remove “Add to Cart” via Layout Update XML Magento 2.1

I'm trying to figure out how to remove the add to cart from specific items only in Magento 2.1 via "Layout Update XML on the product backend. In magento 1.x it was simple <reference name="content"...
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 (...
3
votes
2answers
1k views

How to create “buy now” button which should redirects to onepage checkout

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-...
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
2answers
273 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; ...
3
votes
1answer
2k views

Magento 2: How to remove add to cart template from product detail page

I have to remove add to cart button from product detail page when product store has 0. How to achieve this
3
votes
2answers
3k views

Magento 2 Related products add to cart button issue

I'm using Magento 2 and I've noticed that on the related products block , on the product page , the add to cart button for the related products is actually a check box, and not a properly button.. is ...
2
votes
1answer
1k views

Magento 2 Some item options or their combination are not currently available

We have installed Magento ver. 2.1.6. using composer with sample data. We have call event checkout_cart_product_add_after for adding addition information with item. The event observer code is given ...
2
votes
5answers
2k views

Add to cart button brings you to an empty cart for certain products need help troubleshooting!

So not one person in all of this section can help troubleshoot session issues? NOTE I've completely updated my question as this was never resolved: EDIT: I just noticed that while I set 777 on var/...
2
votes
1answer
2k views

Add to cart configurable products using magento soap api V1

Trying to add configurable product in magento cart using magento soap api V1 but not able to add the products. can anyone please let me know the way how to do it. Any help would be appreciated.
2
votes
2answers
2k views

Adding a Product to the Cart via Querystring using SKU

I know that we can adding a product to cart via querystring. but how do we add sku to cart via querystring in url without including product id like this : domain/checkout/cart/add?sku=ABC or domain/...
2
votes
1answer
2k views

Magento 2 - Quantity Field on Related Products Listing

I'm trying to add a quantity field to the related products section on my product page. I'm overriding module-catalog/view/frontend/templates/product/list/items.phtml in my theme. So far, here is my '...
2
votes
1answer
314 views

Buy now and add to cart in magento [duplicate]

I need an add to cart and buy now button. It is working fine but when I click buy now button, nothing is happening and after a couple of seconds the page is redirecting to the cart page. I need to ...
2
votes
3answers
4k views

Magento 2 add product to cart with custom price from the custom controller?

I have a created a product with price: 0, Now i would like to add a product with custom price from my custom controller. since i am submitting a custom form in the customer dashboard to my controller. ...
2
votes
1answer
246 views

Can't override template file in Magento 2.1 module

I'm trying to override Magento's built-in addtocart.phtml file, but nothing I try seems to be working. I Have a module named QuantityDropdown under the Rethink namespace. As far as I can see it's ...
2
votes
1answer
1k views

Show Pop Up when click on Add to cart Magento 2

Is there any mistake in this code or file structure ? link i followed what i did 1)app/code/SomeName/AddCartPopUp/registration.php <?php \Magento\Framework\Component\ComponentRegistrar::...
1
vote
0answers
160 views

Magento 1.7 Buy Now Button with Custom options and Configurable item checker

I used this approach for the buy now button on product page app/design/frontend/your_template/default/template/catalog/product/view.phtml <script> function setcheckoutLocation(location) { ...
1
vote
1answer
468 views

Product Add to cart before I want to set Product custom option values in Magento2.2

I want to add product to cart with some product already create custom option values put. So what happen current magento create new product in cart while same product different custom options or values....
1
vote
0answers
231 views

Compare item added to cart to items already in cart to check if same attributes

I am having trouble comparing the items already in my cart with the item that was just added to the cart. Since I have attributes that are added via module instead of in each product, the item is just ...
1
vote
1answer
820 views

Changing add to cart button depending on category Id

I have a category of products that can't be bought online directly but that I want to give the functionality of going to a distributors page. For that, I need to retrieve the category id of the ...
1
vote
2answers
251 views

I want two functionalities together

I want to have 2 buttons on the product view page one will just add product to cart and it will not redirect it to cart. However other will add product to cart and also redirect the user to cart. So ...
1
vote
2answers
2k views

Magento 2: Change quote from current quote to other quote id

Please let me know how can I change my current quote to any other quote saved in database using an event observer in magento 2.2
0
votes
1answer
4k views

Update price of item before adding to cart!

Just like the title says I want to change the price of the item before it hits the cart. A customer configures an item before purchasing and different combinations equal different prices. As a ...
0
votes
0answers
266 views

Unable to add product to cart through api in customer's cart. How to do that?

$appEmulation = Mage::getSingleton("core/app_emulation"); $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId); $customer = Mage::getModel("customer/customer")->load($...
0
votes
2answers
4k views

Adding to Cart programmatically is adding to the wrong Store?

I'm trying to add to cart programmatically from store 2, but it's adding products to store 1. How can I force it to add to the correct store? This is the code I've got in my CMS page. include_once "...
0
votes
2answers
294 views

Problem with loading a add to cart button into silder

I have a problem with adding the add to cart button. Whenever I add the add to cart button the all of the sliders disapear from page. This is the example where I use the add to cart button . <...
0
votes
2answers
307 views

how to fix conflict between 2 extensions

Edit I found the reason , i am using this extension : https://github.com/organicinternet/magento-configurable-simpfor that reason its not displaying configurable product in cart page. but i need ...
0
votes
1answer
519 views

Add to cart by URL and Error Handling on 1.9

So I have managed to get rudimentary add to cart links working from external sources. Using the following sources: Official & out of date Wiki This StackOverflow post Here is the working code ...
0
votes
2answers
474 views

Add multiple items to cart in Magento2

I am implementing add to cart functionality from ajax using product id. This is my code of template file <tr class="border_bottom child-items selected"> <td >...
0
votes
0answers
36 views

$_product->isSaleable() shows different value in list page and view page magento 2

Issue: Out of stock set at admin side. On product list page display "Out of stock" while detail page shows "Add to cart" button. I have print the $_product->isSaleable() function on list.phtml as ...
0
votes
0answers
149 views

Suggestions needed: Adding fake product to cart and bring it to order

I have a request to solve a problem and I wanted to ask if somebody has already faced a similar problem and got a good suggestion on how to go about implementing it. We sell car parts (Auto parts) ...
0
votes
1answer
297 views

“We can't add this item to your shopping cart right now” on detail page (Magento2 EE 2.1.7) Update

How to resolve ??? I has changed in vendor\magento\zendframework1\library\Zend\Cache\Backend\File.php:99 Change 'cache_dir' => null to 'cache_dir' => 'var/cache'. And not resolve this. Plsssss ...
0
votes
1answer
831 views

Magento 2 : Add to cart product with custom option programmatically

I want to add to cart product with custom options. I added simple product, but can't able to add with custom options. How to do it ? Please help me. Thanks.
0
votes
1answer
35 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"...