Let’s say you want to create a store view that is browse only. This little snippet is really handy. It will remove the add to cart and qty field on a product thereby rendering you unable to add to basket.  Also really handy making catalog only or trade only sites.

Magento 2 XML Layout Updates – In brief

A layout update is a small bit of code written in XML format that instructs the Magento CMS to look in a particular section of the page and either pick up or put down another piece of code.  In each of the how-to sections below I’ll write out what each of the Magento Layout Updates are doing in a human way so they are more easy to understand. 

So let’s get going

For all examples in this guide of XML updates you will need to:

  • replace block_namespace_here with a custom name for your block such as custom.product.message. This can be anything really that follow this format but try and keep them the same across your site when they are doing the same thing.
  • replace block_identifier_here with the block identifier (the ID of the static block)

Where to add the code

Whether you are doing a Magento XML Layout update on a category, product or CMS page you’ll be looking for a box that looks like this one to make your edits. You can do layout updates on pages, products and categories.

Magento 2 Layout Update from CMS

How to remove Qty and Add to Cart from product page in Magento 2

If you want to make a product page so somebody cannot add to the basket and remove the Qty and add to cart buttons this is really easy to do with a simple xml update.

  1. Use this code in the design xml layout update field on the product to remove the price. You can do it on a product by product basis you could use the bulk update attributes feature.

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

The result of using this code to remove the price can be seen here on our Lumarix Magento Store

Before

Image 2019-08-23 at 3.35.04 pm

After

Image 2019-08-23 at 3.58.15 pm

Why remove the price from a product page in Magento 2

  • Get customers to call to place orders
  • Add a custom message to the page
  • Make a brochure only section of your website

Would you like to learn more? Would you rather we just did these things for you?

Call us on 0117 2077504 or complete the form below to discuss your project or requirements.