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.

asked Mar 15, 2017 at 19:05

2 Answers 2

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.

answered May 25, 2017 at 23:55
4
  • 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! Commented May 29, 2017 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! Commented Aug 2, 2017 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! Commented Aug 2, 2017 at 23:09
  • @biolauri thanks to point out the best practices about spaces around equal sign Commented Aug 3, 2017 at 10:25
1

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

<referenceBlock name="product.info.options.wrapper.bottom" display="false" />
answered Oct 11, 2018 at 10:55

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.