若要防止客戶在不選擇您是如何了解到我們商店的?表單字段中選項的情況下繼續(xù)結(jié)賬,您可以將該字段設(shè)置為必填字段。
在 Config 目錄中,點擊 settings_schema.json
。
在代碼中查找第一個右大括號 },
。在右大括號 },
下方的新行中,粘貼以下代碼:
{ "name": "Hear About Us", "settings": [ { "type": "text", "id": "hau_form_options", "label": "Form options", "default": "Facebook, Twitter, Google, Instagram, Youtube", "info": "Separate each option with a comma" }, { "type": "header", "content": "Form validation" }, { "type": "checkbox", "id": "hau_form_validation", "label": "Enable form validation", "default": true }, { "type": "text", "id": "hau_error_message", "label": "Error message", "info": "The error message that is displayed when no selection is made", "default": "Please select an option below" }, { "type": "text", "id": "hau_error_message_other", "label": "Other field error message", "info": "The error message that is displayed when there is no input in the 'Other' field", "default": "Please fill the text field below" }, { "type": "header", "content": "Error styling" }, { "type": "color", "id": "hau_error_color", "label": "Color", "default": "#ff0000" } ] },
點擊保存。
若要防止客戶在不選擇您是如何了解到我們商店的?表單字段中選項的情況下繼續(xù)結(jié)賬,您可以將該字段設(shè)置為必填字段。
在 Sections 目錄中,點擊 cart-template.liquid
。如果您的模板中不包含 cart-template.liquid
,請點擊 Templates 目錄中的 cart.liquid
。
在購物車表單字段中查找以下 novalidate
屬性:
novalidate
將 novalidate
屬性替換為以下代碼:
{% unless settings.hau_form_validation %}novalidate{% endunless %}
點擊保存。
在模板編輯器中,點擊側(cè)邊欄上的模板設(shè)置。
點擊了解我們選項卡。
在表單驗證下,確保已啟用啟用表單驗證設(shè)置。
備注:您可以通過修改錯誤消息和其他字段錯誤消息文本字段設(shè)置來自定義顯示的錯誤消息。您還可以通過更改錯誤樣式下的顏色設(shè)置來自定義錯誤顏色。
Include the snippet in your cart page
To include the How did you hear about us? snippet in your cart page:
In the Sections directory, click
cart-template.liquid
. If your theme doesn't include acart-template.liquid
, then clickcart.liquid
in the Templates directory.Find the closing
</form>
tag in the code. On a new line above the closing</form>
tag, paste the following code:{% render 'hear-about-us' %}Click Save.
Add theme settings for configuration
In the Config directory, click
settings_schema.json
.Find the first closing curly bracket
},
in the code. On a new line below the closing curly bracket},
, paste the following code:{ "name": "Hear About Us", "settings": [ { "type": "text", "id": "hau_form_options", "label": "Form options", "default": "Facebook, Twitter, Google, Instagram, Youtube", "info": "Separate each option with a comma" }, { "type": "header", "content": "Form validation" }, { "type": "checkbox", "id": "hau_form_validation", "label": "Enable form validation", "default": true }, { "type": "text", "id": "hau_error_message", "label": "Error message", "info": "The error message that is displayed when no selection is made", "default": "Please select an option below" }, { "type": "text", "id": "hau_error_message_other", "label": "Other field error message", "info": "The error message that is displayed when there is no input in the 'Other' field", "default": "Please fill the text field below" }, { "type": "header", "content": "Error styling" }, { "type": "color", "id": "hau_error_color", "label": "Color", "default": "#ff0000" } ] },Click Save.
Make the form field required
To prevent customers from ceeding to the checkout without selecting an option in the How did you hear about us? form field, you can make the field required.
In the Sections directory, click
cart-template.liquid
. If your theme doesn't include acart-template.liquid
, then clickcart.liquid
in the Templates directory.Find the following
novalidate
attribute in the cart form code:novalidateRepla the
novalidate
attribute with the following code:{% unless settings.hau_form_validation %}novalidate{% endunless %}Click Save.
In the theme editor, click Theme settings on the sidebar.
Click the Hear About Us tab.
Under Form Validation, make sure the Enable form validation setting is enabled.
特別聲明:以上文章內(nèi)容僅代表作者本人觀點,不代表ESG跨境電商觀點或立場。如有關(guān)于作品內(nèi)容、版權(quán)或其它問題請于作品發(fā)表后的30日內(nèi)與ESG跨境電商聯(lián)系。
二維碼加載中...
使用微信掃一掃登錄
使用賬號密碼登錄
平臺顧問
微信掃一掃
馬上聯(lián)系在線顧問
小程序
ESG跨境小程序
手機入駐更便捷
返回頂部