1

I have created a new page in phtml in Magento 2 and have listed there some products and from there want to add a product to cart with php/ajax , and wan't to know which is the best way to do it.

P.S. It's not duplicated, because I dont get checkouturl in the right way.

marked as duplicate by Jai, Keyur Shah, Prince Patel, Manashvi Birla, liyakat Dec 29 '17 at 5:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • thank you for your comment, I tried the code, and at the form action $addtocarturl even the url is correct, adds 3 characters "%2C" This is the full url: checkout/cart/add/uenc/aHR0cHM6Ly93d3cudGliby50di8yMDE4OS9ibGk%2C/product/4/ And while is adding the characters %2C it doesn't add the product to the cart, but when I modify it in inspect element, than it add the product to the cart – Algert Zh Dec 28 '17 at 13:23
  • Check the product QTY – Mandar Parbate Dec 28 '17 at 13:33
  • I think QTY its fine, have set it to 50 – Algert Zh Dec 28 '17 at 13:37

Browse other questions tagged or ask your own question.