Как добавить пользовательское поле на страницу продукта Shopify?

Добавление пользовательского поля на страницу товара Shopify — это отличный способ продемонстрировать уникальные характеристики вашего продукта и убедиться, что у покупателей есть вся информация, необходимая для совершения покупки. Существует несколько различных способов добавления пользовательских полей на страницы товаров, поэтому мы расскажем вам об этом пошагово.

Прежде всего, вам нужно создать новый шаблон продукта. Для этого перейдите в Shopify Admin > Online Store > Themes.

Найдите тему, которую вы сейчас используете, а затем нажмите Actions > Edit code.

В директории Шаблоны нажмите на product.liquid. Если вы не видите этого файла, значит, у вашей темы его нет, и вам нужно его создать. Для этого нажмите на выпадающее меню «Добавить новый шаблон « и выберите «product «.

После того как вы нашли или создали шаблон продукта, найдите следующую строку кода:

{{ product.description }}

Это место, где описание товара Shopify по умолчанию отображается на страницах вашего товара. Мы собираемся заменить его нашим пользовательским полем.

Для этого нам сначала нужно создать новый сниппет. Сниппеты — это небольшие фрагменты кода, которые можно повторно использовать в разных местах вашей темы.

Чтобы создать новый сниппет, вернитесь в директорию Templates и нажмите на «Add a new template «. This time, select "snippet".

Name your snippet something memorable like “custom-field” and then click “Create snippet”. Once you’ve created your snippet, paste the following code into it:

{{ product.custom\_field }}

This code will display the contents of your custom field on the front-end of your store.

PRO TIP: If you are not comfortable working with code, we recommend finding a Shopify Expert to help you with this.

Conclusion: How Do I Add a Custom Field to My Shopify Product Page?

Adding a custom field to your Shopify product page is a great way show off unique features about your product and ensure customers have all information they need before making purchase. There are few different ways add custom fields, which vary depending on what type of field it is (text input, radio button, drop down menu, etc.), but follow these steps as general guide:

  1. From Shopify admin panel, go to Online Store > Themes > choose theme you want to edit
  2. Click “Actions” then “Edit Code”
  3. Under “Templates” find “product.liquid” file – if not visible, create one by selecting “Add New Template” from drop down menu and choosing “Product” option
  4. Once located/created, look for line of code reading: {{ product.description }} and replace with following:
    {{ product.custom_field }}

    ; This will display contents of custom field on front end store