Custom coding to hide prices except when logged in

Hello, I need my store to be able to show, beneath the product image that prices will be shown when logged in.

now I found some coding here ; https://originateweb.com/hide-prices-on-some-products-on-shopify-store/

but can’t seam to finish the coding as the message shown in the picture below keeps on appearing:

can someone help me.

thanks

  1. Inside the template file, find the code that displays the product price. It could be a snippet like {{ product.price }} or something similar.

  2. Wrap the code that displays the price with an {% if %} statement to check the user’s login status. You can use the customer object to access the customer information.

{% if customer %}
  {{ product.price }}
{% else %}
  

Prices will be shown when logged in

{% endif %}

Hello @Academiebel

Please replace the product.requires-contact.json template code with the following code:

{
  "sections": {
    "main": {
      "type": "main-product",
      "blocks": {
        "vendor": {
          "type": "text",
          "settings": {
            "text": "{{ product.vendor }}",
            "text_style": "uppercase"
          }
        },
        "title": {
          "type": "title",
          "settings": {
          }
        },
        "caption": {
          "type": "text",
          "settings": {
            "text": "{{ product.metafields.descriptors.subtitle.value }}",
            "text_style": "subtitle"
          }
        },
        "price": {
          "type": "price",
          "settings": {
          }
        },
        "variant_picker": {
          "type": "variant_picker",
          "settings": {
            "picker_type": "button"
          }
        },
        "quantity_selector": {
          "type": "quantity_selector",
          "settings": {
          }
        },
        "buy_buttons": {
          "type": "buy_buttons",
          "settings": {
            "show_dynamic_checkout": true
          }
        },
        "description": {
          "type": "description",
          "settings": {
          }
        },
        "collapsible-row-0": {
          "type": "collapsible_tab",
          "settings": {
            "heading": "Materials",
            "icon": "leather",
            "content": "",
            "page": ""
          }
        },
        "collapsible-row-1": {
          "type": "collapsible_tab",
          "settings": {
            "heading": "Shipping & Returns",
            "icon": "truck",
            "content": "",
            "page": ""
          }
        },
        "collapsible-row-2": {
          "type": "collapsible_tab",
          "settings": {
            "heading": "Dimensions",
            "icon": "ruler",
            "content": "",
            "page": ""
          }
        },
        "collapsible-row-3": {
          "type": "collapsible_tab",
          "settings": {
            "heading": "Care Instructions",
            "icon": "heart",
            "content": "",
            "page": ""
          }
        },
        "share": {
          "type": "share",
          "settings": {
            "share_label": "Share"
          }
        }
      },
      "block_order": [
        "vendor",
        "title",
        "caption",
        "price",
        "variant_picker",
        "quantity_selector",
        "buy_buttons",
        "description",
        "collapsible-row-0",
        "collapsible-row-1",
        "collapsible-row-2",
        "collapsible-row-3",
        "share"
      ],
      "settings": {
        "enable_sticky_info": true,
        "media_size": "large",
        "gallery_layout": "stacked",
        "mobile_thumbnails": "hide",
        "hide_variants": true,
        "enable_video_looping": false,
        "padding_top": 36,
        "padding_bottom": 12
      }
    },
    "image-with-text": {
      "type": "image-with-text",
      "blocks": {
        "image-with-text-0": {
          "type": "heading",
          "settings": {
            "heading": "Image with text",
            "heading_size": "h1"
          }
        },
        "image-with-text-1": {
          "type": "text",
          "settings": {
            "text": "

Pair text with an image to focus on your chosen product, collection, or blog post. Add details on availability, style, or even provide a review.<\/p>",
            "text_style": "body"
          }
        }
      },
      "block_order": [
        "image-with-text-0",
        "image-with-text-1"
      ],
      "settings": {
        "height": "small",
        "desktop_image_width": "medium",
        "layout": "text_first",
        "desktop_content_position": "top",
        "desktop_content_alignment": "left",
        "content_layout": "no-overlap",
        "color_scheme": "background-2",
        "mobile_content_alignment": "left",
        "padding_top": 36,
        "padding_bottom": 36
      }
    },
    "multicolumn": {
      "type": "multicolumn",
      "blocks": {
        "column-0": {
          "type": "column",
          "settings": {
            "title": "Free Shipping",
            "text": "

Pair text with an image to focus on your chosen product, collection, or blog post. Add details on availability, style, or even provide a review.<\/p>",
            "link_label": "",
            "link": ""
          }
        },
        "column-1": {
          "type": "column",
          "settings": {
            "title": "Hassle-Free Exchanges",
            "text": "

Pair text with an image to focus on your chosen product, collection, or blog post. Add details on availability, style, or even provide a review.<\/p>",
            "link_label": "",
            "link": ""
          }
        }
      },
      "block_order": [
        "column-0",
        "column-1"
      ],
      "settings": {
        "title": "",
        "heading_size": "h1",
        "image_width": "full",
        "image_ratio": "adapt",
        "columns_desktop": 2,
        "column_alignment": "left",
        "background_style": "none",
        "button_label": "",
        "button_link": "",
        "color_scheme": "background-1",
        "columns_mobile": "1",
        "swipe_on_mobile": false,
        "padding_top": 36,
        "padding_bottom": 36
      }
    }
  },
  "order": [
    "main",
    "image-with-text",
    "multicolumn"
  ]
}

Please hit Like and Mark it as a Solution if you find our reply helpful.