4

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">
  <remove name="product.info.addtocart"/>
</reference>

However, I haven't found a nice clean and simple method to use for Magento 2.1 - is there something similar to use on a per-item basis via update XML?

EDIT: Ok, never could figure out anything to put the the layout XML that would remove the Add to Cart button. But I did find a crappy way to do it - CSS.

Add this into the top of the Content on the product you want to hide the add to cart

<style>.box-tocart {display: none}</style>

Far from ideal, but it does get the job sort of done.

6

This is possible, but the syntax has changed. Try using

<referenceBlock name="product.info.addtocart" remove="true" />


The Magento 2 DevDocs have some info about the new XML instructions.

  • Only 2 tiny thing to change <referenceBlock name="product.info.addtocart" remove="true" /> The answer you posted was addtocard. But thank you so much, this is so easy! – dawhoo May 29 '17 at 12:39
  • Oh, my bad, now I corrected it! And I misread your comment: I didn't know what you meant at first glance, so I virtually ignored it. Sorry about that! – biolauri Aug 2 '17 at 23:04
  • And, my apologies to @siddhesh, too! I also misread your edit and thought, you were only adding the spaces between the equal signs. So I reverted it, because it's best practice to omit them. But finally, your main edit is in the answer (no addtocard with d anymore). I'm sorry about that! – biolauri Aug 2 '17 at 23:09
  • @biolauri thanks to point out the best practices about spaces around equal sign – siddhesh Aug 3 '17 at 10:25
1

Remove add to cart button from configurable product's PDP page:

<referenceBlock name="product.info.options.wrapper.bottom" display="false" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.