Remove Item Options and Add to Cart Button Per Item Record

Written by
Ryan
Published on
July 20, 2023 at 3:22:27 AM PDT July 20, 2023 at 3:22:27 AM PDTth, July 20, 2023 at 3:22:27 AM PDT

Scenario

Currently, un-checking the "Don't Show Price" checkbox in the Web Store tab of an item record, removes the "Add to cart" button per item product page. That will also hide the price of the item. This option will not hide the item options for matrices as well as the custom ones.

Solution

The following steps can allow users to display the item price without displaying the item options and the Add to cartbutton:

  1. Navigate to Customization > Lists, Records & Fields > Item Fields > New
  2. Set the following:
    • Label: Enter Hide Add to Cart Button
    • Store Value: Enter Checkmark
    • Applies To: Enter Checkmark (on all the item types you want to control)
    • Display: Select where you want the check box to show in the item record
  3. Click Save
  4. Navigate to Commerce > Site Builder > Item/Category Templates
  5. Edit the Item List Cell, Related Item List Cell and Drilldown Template being used in the web store
  6. Search for the "START ADD" text in the HTML comment
  7. Following that line, add this:
    • <script type='text/javascript'>
      if("Yes" == "<%=getCurrentAttribute('item','custitem21')%>"){
      document.getElementById('addtocartbutton<%=getCurrentAttribute('item','internalid')%>').style.display = "none";
      document.getElementById('itemprice<%=getCurrentAttribute('item','internalid')%>').style.display = "block";
      }
      </script>
  8. Search for the "END ADD"
  9. Prior to that line, insert</span>

  10. ClickSave

    Note:This will only work if the web site is using the correct layout which the modified template is associated