询问客户了解您商店的途径

您可以通过向购物车页面添加您是如何了解到我们商店的?表单字段来询问客户了解您商店的途径。

您是如何了解到我们商店的

创建“您是如何了解到我们商店的?”表单字段

在购物车页面中包含代码片段

若要在购物车页面中包含您是如何了解到我们商店的?代码片段,请执行以下操作:

  1. Sections 目录中,点击 cart-template.liquid。如果您的模板中不包含 cart-template.liquid,请点击 Templates 目录中的 cart.liquid

  2. 查找代码中的结束 </form> 标记。在结束 </form> 标记上方的新行中,粘贴以下代码:

{% render 'hear-about-us' %}
  1. 点击保存

为配置添加模板设置

  1. Config 目录中,点击 settings_schema.json

  2. 在代码中查找第一个右大括号 },。在右大括号 }, 下方的新行中,粘贴以下代码:

{
"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"
    }
]
},
  1. 点击保存

将表单字段设置为必填字段

若要防止客户在不选择您是如何了解到我们商店的?表单字段中选项的情况下继续结账,您可以将该字段设置为必填字段。

  1. Sections 目录中,点击 cart-template.liquid。如果您的模板中不包含 cart-template.liquid,请点击 Templates 目录中的 cart.liquid

  2. 在购物车表单字段中查找以下 novalidate 属性:

novalidate
  1. novalidate 属性替换为以下代码:
{% unless settings.hau_form_validation %}novalidate{% endunless %}
  1. 点击保存

  2. 模板编辑器中,点击侧边栏上的模板设置

  3. 点击了解我们选项卡。

  4. 表单验证下,确保已启用启用表单验证设置。

备注:您可以通过修改错误消息其他字段错误消息文本字段设置来自定义显示的错误消息。您还可以通过更改错误样式下的颜色设置来自定义错误颜色。

设置选项

若要自定义您是如何了解到我们商店的?下拉菜单中的选项,您可以使用模板编辑器中的模板设置来编辑选项。

  1. 模板编辑器中,点击模板设置

  2. 点击了解我们选项卡。

  3. 表单选项下,添加或删除选项(用逗号分隔)。

  4. 点击保存

备注:请勿包含选项其他,因为系统会自动添加该选项。

常见问题解答

在哪里可以看到获取的数据?

您将在后台中订单的其他详情部分中看到答案:

订单的其他详情部分

如果列出的选项都不是答案,客户可以键入内容吗?

可以。客户选择其他后,下拉菜单下方将出现一个文本框,可在其中键入答案。

我可以在“新订单通知电子邮件”中显示答案吗?

可以。若要在“新订单通知电子邮件”中显示客户回复,请执行以下操作:

  1. 转到后台中的通知页面,然后向您的新订单电子邮件模板中添加以下代码:
This customer heard about us through {% if attributes.how-did-you-hear-about-us-other == blank %}{{ attributes.how-did-you-hear-about-us }}{% else %}{{ attributes.how-did-you-hear-about-us-other }}{% endif %}.
  1. 点击保存

准备好开始使用 Shopify 进行销售了吗?

免费试用