title: Remove "Add To Carts" button in certain categories on Magento2
body: <p>I'm a noob when it comes to PHP.</p>
  
  <p>However, my employer is asking me to hide the "Add To Cart" button for products in certain categories. I'm wondering if any of you could take a look and help me solve the problem</p>
  
  <p>I appreciate any help you may be able to offer. Unfortunately this task is above my head and the other answers on this don't clearly specify what I need to change.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  /**
   * Copyright © Magento, Inc. All rights reserved.
   * See COPYING.txt for license details.
   */
  
  // @codingStandardsIgnoreFile
  
  /** @var $block \Magento\Catalog\Block\Product\View */
  ?&gt;
  
  
  &lt;?php
  $helper                  = $this-&gt;helper("Lof\RequestForQuote\Helper\Data");
  $enable = $helper-&gt;isEnabledQuote();
  $disable_qty = $helper-&gt;getConfig('general/disable_qty');
  $disable_qty = ($disable_qty !==null)?(int)$disable_qty:0;
  $disable_addtocart = $helper-&gt;getConfig('general/disable_addtocart');
  $disable_addtocart = ($disable_addtocart !==null)?(int)$disable_addtocart:0;
  $enable_addtoquote = $helper-&gt;getConfig('general/enable_addtoquote');
  $enable_addtoquote = ($enable_addtoquote !==null)?(int)$enable_addtoquote:1;
  ?&gt;
  &lt;?php $_product = $block-&gt;getProduct(); ?&gt;
  &lt;?php if ($enable &amp;&amp; $disable_addtocart &amp;&amp; ($enable_addtoquote || ($_product-&gt;hasData('product_quote') &amp;&amp; $_product-&gt;getData('product_quote')))) {
      ?&gt;
  &lt;div class="box-tocart"&gt;
      &lt;div class="fieldset"&gt;
          &lt;?php if ($block-&gt;shouldRenderQuantity() &amp;&amp; !$disable_qty): ?&gt;
          &lt;div class="field qty"&gt;
              &lt;label class="label" for="qty"&gt;&lt;span&gt;&lt;?= /* @escapeNotVerified */ __('Qty') ?&gt;&lt;/span&gt;&lt;/label&gt;
              &lt;div class="control"&gt;
                  &lt;input type="number"
                         name="qty"
                         id="qty"
                         value="&lt;?= /* @escapeNotVerified */ $block-&gt;getProductDefaultQty() * 1 ?&gt;"
                         title="&lt;?= /* @escapeNotVerified */ __('Qty') ?&gt;"
                         class="input-text qty"
                         data-validate="&lt;?= $block-&gt;escapeHtml(json_encode($block-&gt;getQuantityValidators())) ?&gt;"
                         /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;?php endif; ?&gt;
          &lt;div class="actions"&gt;
              &lt;?= $block-&gt;getChildHtml('', true) ?&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;?php if ($block-&gt;isRedirectToCartEnabled()) : ?&gt;
  &lt;script type="text/x-magento-init"&gt;
      {
          "#product_addtocart_form": {
              "Magento_Catalog/product/view/validation": {
                  "radioCheckboxClosest": ".nested"
              }
          }
      }
  &lt;/script&gt;
  &lt;?php else : ?&gt;
  &lt;script type="text/x-magento-init"&gt;
      {
          "#product_addtocart_form": {
              "Magento_Catalog/js/validate-product": {}
          }
      }
  &lt;/script&gt;
  &lt;?php endif; ?&gt;
      &lt;?php
   } else { ?&gt;
  &lt;?php $buttonTitle = __('Add to Cart'); ?&gt;
  &lt;?php if ($_product-&gt;isSaleable()): ?&gt;
  &lt;div class="box-tocart"&gt;
      &lt;div class="fieldset"&gt;
          &lt;?php if ($block-&gt;shouldRenderQuantity()): ?&gt;
          &lt;div class="field qty"&gt;
              &lt;label class="label" for="qty"&gt;&lt;span&gt;&lt;?= /* @escapeNotVerified */ __('Qty') ?&gt;&lt;/span&gt;&lt;/label&gt;
              &lt;div class="control"&gt;
                  &lt;input type="number"
                         name="qty"
                         id="qty"
                         value="&lt;?= /* @escapeNotVerified */ $block-&gt;getProductDefaultQty() * 1 ?&gt;"
                         title="&lt;?= /* @escapeNotVerified */ __('Qty') ?&gt;"
                         class="input-text qty"
                         data-validate="&lt;?= $block-&gt;escapeHtml(json_encode($block-&gt;getQuantityValidators())) ?&gt;"
                         /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;?php endif; ?&gt;
          &lt;div class="actions"&gt;
              &lt;button type="submit"
                      title="&lt;?= /* @escapeNotVerified */ $buttonTitle ?&gt;"
                      class="action primary tocart"
                      id="product-addtocart-button"&gt;
                  &lt;span&gt;&lt;?= /* @escapeNotVerified */ $buttonTitle ?&gt;&lt;/span&gt;
              &lt;/button&gt;
              &lt;?= $block-&gt;getChildHtml('', true) ?&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;?php endif; ?&gt;
  &lt;?php if ($block-&gt;isRedirectToCartEnabled()) : ?&gt;
  &lt;script type="text/x-magento-init"&gt;
      {
          "#product_addtocart_form": {
              "Magento_Catalog/product/view/validation": {
                  "radioCheckboxClosest": ".nested"
              }
          }
      }
  &lt;/script&gt;
  &lt;?php else : ?&gt;
  &lt;script type="text/x-magento-init"&gt;
      {
          "#product_addtocart_form": {
              "Magento_Catalog/js/validate-product": {}
          }
      }
  &lt;/script&gt;
  &lt;?php endif; ?&gt;
  
  &lt;?php } ?&gt;</code></pre>
  </div>
  </div>
  </p>