shopify½¨Éè¡°ÄúÊÇÔõÑùÏàʶµ½ÎÒÃÇÊÐËÁµÄ£¿£¿£¿£¿£¿£¿£¿£¿¡±±íµ¥×ֶΰ취
ѯÎʿͻ§ÏàʶÄúÊÐËÁµÄ;¾¶
±¸×¢
ÈôÊÇÄúʹÓà Shopify µÄÃâ·ÑÄ£°å£¬£¬£¬£¬£¬Äú¿ÉÒÔÁªÏµ Shopify Ö§³ÖÍŶӻñµÃ¹ØÓڴ˽̵̳Ä×ÊÖú¡£¡£¡£¡£¡£´Ë½Ì³ÌÐèÒª 15 ·ÖÖÓµÄÉè¼ÆÊ±¼ä¡£¡£¡£¡£¡£ÈôÒªÏàʶÏêÇ飬£¬£¬£¬£¬Çë²ÎÔÄ Support for themes¡£¡£¡£¡£¡£
±¸×¢
´Ë×Ô½ç˵ÓÃÓÚ¸´¹Å Shopify Ä£°å£¬£¬£¬£¬£¬²»ÊÊÓÃÓÚ¡°Online Store 2.0¡±Ä£°å¡£¡£¡£¡£¡£
ÕÒµ½ÄúµÄÄ£°å¼Ü¹¹°æ±¾
̽Ë÷¡°Online Store 2.0¡±Ä£°å×Ô½ç˵
Äú¿ÉÒÔͨ¹ýÏò¹ºÎï³µÒ³ÃæÌí¼ÓÄúÊÇÔõÑùÏàʶµ½ÎÒÃÇÊÐËÁµÄ£¿£¿£¿£¿£¿£¿£¿£¿±íµ¥×Ö¶ÎÀ´Ñ¯Îʿͻ§ÏàʶÄúÊÐËÁµÄ;¾¶¡£¡£¡£¡£¡£
×¢ÖØ
´Ë×Ô½ç˵ÉèÖò»ÊÊÓÃÓÚ³éÌëʽ»òµ¯³öʽ¹ºÎï³µ£¬£¬£¬£¬£¬½öÊÊÓÃÓÚ¹ºÎï³µÒ³Ãæ£¨Î»ÓÚ URL your-store.com/cart£©¡£¡£¡£¡£¡£ÈôÊÇÄúʹÓùºÎï³µ³éÌë»òµ¯³öʽ¹ºÎï³µ£¬£¬£¬£¬£¬Äú½«ÐèÒªÔÚÄ£°å±à¼Æ÷Öн«ÄúµÄ¹ºÎï³µÑùʽ¸ü¸ÄΪ¹ºÎï³µÒ³Ãæ¡£¡£¡£¡£¡£ÔÚÄ£°åÔ¤ÀÀÖÐÏò¹ºÎï³µÖÐÌí¼Ó²úÆ·£¬£¬£¬£¬£¬È»ºóµã»÷Ä£°å±à¼Æ÷ÖеĹºÎï³µÒ³ÃæÑ¡Ï£¬£¬£¬£¬£¬ÒÔÉó²éÄúµÄ¹ºÎï³µÉèÖᣡ£¡£¡£¡£
½¨Éè¡°ÄúÊÇÔõÑùÏàʶµ½ÎÒÃÇÊÐËÁµÄ£¿£¿£¿£¿£¿£¿£¿£¿¡±±íµ¥×Ö¶Î
ÈôÒª½¨ÉèÄúÊÇÔõÑùÏàʶµ½ÎÒÃÇÊÐËÁµÄ£¿£¿£¿£¿£¿£¿£¿£¿±íµ¥×ֶΣ¬£¬£¬£¬£¬ÇëÖ´ÐÐÒÔϲÙ×÷£º
PC£º
ÕÒµ½Òª±à¼µÄÄ£°å£¬£¬£¬£¬£¬È»ºóµã»÷²Ù×÷ > ±à¼´úÂë¡£¡£¡£¡£¡£
ÔÚ Snippets Ŀ¼Öеã»÷Ìí¼ÓÐÂÆ¬¶Ï¡£¡£¡£¡£¡£
½¨Éè´úÂëÆ¬¶Ï£º
½«´úÂëÆ¬¶ÏÃüÃûΪ
hear-about-us¡£¡£¡£¡£¡£µã»÷½¨ÉèÆ¬¶Ï¡£¡£¡£¡£¡£
Æ»¹ûϵͳ£º
ÔÚ Shopify Ó¦ÓÃÖУ¬£¬£¬£¬£¬Çá´¥ÊÐËÁ¡£¡£¡£¡£¡£
ÔÚÏúÊÛÇþµÀ²¿·ÖÖУ¬£¬£¬£¬£¬Çá´¥ÔÚÏßÊÐËÁ¡£¡£¡£¡£¡£
Çá´¥ Manage themes£¨ÖÎÀíÄ£°å£©¡£¡£¡£¡£¡£
ÕÒµ½Òª±à¼µÄÄ£°å£¬£¬£¬£¬£¬È»ºóµã»÷²Ù×÷ > ±à¼´úÂë¡£¡£¡£¡£¡£
ÔÚ Snippets Ŀ¼Öеã»÷Ìí¼ÓÐÂÆ¬¶Ï¡£¡£¡£¡£¡£
½¨Éè´úÂëÆ¬¶Ï£º
½«´úÂëÆ¬¶ÏÃüÃûΪ
hear-about-us¡£¡£¡£¡£¡£µã»÷½¨ÉèÆ¬¶Ï¡£¡£¡£¡£¡£
°²×¿ÏµÍ³£º
ÔÚ Shopify Ó¦ÓÃÖУ¬£¬£¬£¬£¬Çá´¥ÊÐËÁ¡£¡£¡£¡£¡£
ÔÚÏúÊÛÇþµÀ²¿·ÖÖУ¬£¬£¬£¬£¬Çá´¥ÔÚÏßÊÐËÁ¡£¡£¡£¡£¡£
Çá´¥ Manage themes£¨ÖÎÀíÄ£°å£©¡£¡£¡£¡£¡£
ÕÒµ½Òª±à¼µÄÄ£°å£¬£¬£¬£¬£¬È»ºóµã»÷²Ù×÷ > ±à¼´úÂë¡£¡£¡£¡£¡£
ÔÚ Snippets Ŀ¼Öеã»÷Ìí¼ÓÐÂÆ¬¶Ï¡£¡£¡£¡£¡£
½¨Éè´úÂëÆ¬¶Ï£º
½«´úÂëÆ¬¶ÏÃüÃûΪ
hear-about-us¡£¡£¡£¡£¡£µã»÷½¨ÉèÆ¬¶Ï¡£¡£¡£¡£¡£
ÔÚеÄ
hear-about-us.liquid´úÂëÆ¬¶ÏÖУ¬£¬£¬£¬£¬Õ³ÌùÒÔÏ´úÂ룺
```liquid <style> #how-did-you-hear-about-us--label, #how-did-you-hear-about-us-other--label { font-weight: bold; } select#how-did-you-hear-about-us, input#how-did-you-hear-about-us-other { width: 100%; padding: 8px 10px 8px 10px; line-height: 1.2; } #how-did-you-hear-about-us, #how-did-you-hear-about-us-other, #how-did-you-hear-about-us--label, #how-did-you-hear-about-us--error, #how-did-you-hear-about-us-other--label, #how-did-you-hear-about-us-other--error { display:block; margin-bottom: 5px; } #how-did-you-hear-about-us-other.error, #how-did-you-hear-about-us.error { border: 2px solid {{ settings.hau_error_color }}; } #how-did-you-hear-about-us--error, #how-did-you-hear-about-us-other--error { color: {{ settings.hau_error_color }}; } </style> <div> <p> <label id="how-did-you-hear-about-us--label" for="how-did-you-hear-about-us">How did you hear about us?</label> <span id="how-did-you-hear-about-us--error" style="display:none">{{ settings.hau_error_message }}</span> <select id="how-did-you-hear-about-us" name="attributes[how-did-you-hear-about-us]"> <option value=""{% if cart.attributes.how-did-you-hear-about-us == "" %} selected{% endif %}>Please make a selection</option> {% assign optionsArray = settings.hau_form_options | split: ',' %} {% for o in optionsArray %} {% assign option = o | strip %} <option value="{{ option }}"{% if cart.attributes.how-did-you-hear-about-us == option %} selected{% endif %}>{{ option }}</option> {% endfor %} <option value="Other"{% if cart.attributes.how-did-you-hear-about-us == "Other" %} selected{% endif %}>Other</option> </select> </p> <p id="otherFormWrapper" style="{% unless cart.attributes.how-did-you-hear-about-us == 'Other' %}display:none{% endunless %}"> <label id="how-did-you-hear-about-us-other--label" for="how-did-you-hear-about-us-other">Other</label> <span id="how-did-you-hear-about-us-other--error" style="display:none">{{ settings.hau_error_message_other }}</span> <input id="how-did-you-hear-about-us-other" type="text" name="attributes[how-did-you-hear-about-us-other]" value="{{ cart.attributes.how-did-you-hear-about-us-other }}"/> </p> </div> <script> (function() { document.addEventListener("DOMContentLoaded", initForm); document.addEventListener("shopify:section:load", initForm); function initForm(){ var formElement = document.querySelector('#how-did-you-hear-about-us'); var formError = document.querySelector('#how-did-you-hear-about-us--error'); var otherFormElement = document.querySelector('#how-did-you-hear-about-us-other'); var otherFormError = document.querySelector('#how-did-you-hear-about-us-other--error'); var otherFormWrapper = document.querySelector('#otherFormWrapper'); var checkoutButtons = document.querySelectorAll('[name="checkout"], [name="goto_pp"], [name="goto_gc"]'); function showOrHideForm(){ if (formElement.value == 'Other'){ otherFormWrapper.style.display = ''; } else { otherFormWrapper.style.display = 'none'; } } function checkFormElement(){ if (formElement.value.length == 0){ formElement.classList.add('error'); formError.style.display = ''; } else { if (formElement.classList.contains('error')){ formElement.classList.remove('error'); formError.style.display = 'none'; } } } function checkOtherFormElement(){ if (otherFormElement.value.length == 0){ otherFormElement.classList.add('error'); otherFormError.style.display = ''; } else { if (otherFormElement.classList.contains('error')){ otherFormElement.classList.remove('error'); otherFormError.style.display = 'none'; } } } otherFormElement.addEventListener("input", function() { {% if settings.hau_form_validation %} checkOtherFormElement(); {% endif %} }); formElement.addEventListener("change", function() { showOrHideForm(); {% if settings.hau_form_validation %} checkFormElement(); {% endif %} }); checkoutButtons.forEach(function(element){ element.addEventListener("click", function(evt) { {% if settings.hau_form_validation %} var validated = true; if (formElement.value.length == 0){ checkFormElement(); validated = false; } if (formElement.value == 'Other'){ if (otherFormElement.value.length == 0){ checkOtherFormElement(); validated = false; } } if (!validated) { evt.preventDefault(); evt.stopPropagation(); } {% endif %} }); }); } })() </script>1. µã»÷**ÉúÑÄ**¡£¡£¡£¡£¡£ ## ÔÚ¹ºÎï³µÒ³ÃæÖаüÀ¨´úÂëÆ¬¶Ï ÈôÒªÔÚ¹ºÎï³µÒ³ÃæÖаüÀ¨**ÄúÊÇÔõÑùÏàʶµ½ÎÒÃÇÊÐËÁµÄ£¿£¿£¿£¿£¿£¿£¿£¿**´úÂëÆ¬¶Ï£¬£¬£¬£¬£¬ÇëÖ´ÐÐÒÔϲÙ×÷£º 1. ÔÚ **Sections** Ŀ¼ÖУ¬£¬£¬£¬£¬µã»÷ `cart-template.liquid`¡£¡£¡£¡£¡£ÈôÊÇÄúµÄÄ£°åÖв»°üÀ¨ `cart-template.liquid`£¬£¬£¬£¬£¬Çëµã»÷ **Templates** Ŀ¼ÖÐµÄ `cart.liquid`¡£¡£¡£¡£¡£ 2. [²éÕÒ](/manual/shopify-admin/productivity-tools/keyboard-shortcuts#find)´úÂëÖеĿ¢Ê `</form>` ±ê¼Ç¡£¡£¡£¡£¡£ÔÚ¿¢Ê `</form>` ±ê¼ÇÉÏ·½µÄÐÂÐÐÖУ¬£¬£¬£¬£¬Õ³ÌùÒÔÏ´úÂ룺 ```liquid {% render 'hear-about-us' %}µã»÷ÉúÑÄ¡£¡£¡£¡£¡£
ShopifyÉÌ»§¹ÙÍøÔÎÄÏêÇ飺
Ask how customers heard about your store
Note
If you use a free theme from Shopify, then you might be able to contact Shopify Support for help with this tutorial. It requires 15 minutes of design time. To learn more, refer to Support for themes.
Note
This customization is for vintage Shopify themes, and doesn't apply to Online Store 2.0 themes.
Find out your theme's architecture version
Explore Online Store 2.0 theme customizations
You can ask your customers how they heard about your store by adding a How did you hear about us? form field to your cart page.
Caution
This customization will not work for drawer or pop-up cart styles, and will only work for a cart page (at the URL
your-store.com/cart). If you use a cart drawer or pop-up, then you will need to change your cart style to Page in the theme editor. Add a product to the cart in the theme preview, and then click the Cart page tab in the theme editor to view your cart settings.Create the 'How did you hear about us?' form field
To create the How did you hear about us? form field:
PC£º
From your Shopify admin, go to Online Store > Themes.
Find the theme you want to edit, and then click Actions > Edit code.
In the Snippets directory, click Add a new snippet.
Create the snippet:
Name your snippet
hear-about-us.Click Create snippet.
iPhone£º
From the Shopify app, tap Store.
In the Sales channels section, tap Online Store.
Tap Manage themes.
Find the theme you want to edit, and then click Actions > Edit code.
In the Snippets directory, click Add a new snippet.
Create the snippet:
Name your snippet
hear-about-us.Click Create snippet.
Android£º
From the Shopify app, tap Store.
In the Sales channels section, tap Online Store.
Tap Manage themes.
Find the theme you want to edit, and then click Actions > Edit code.
In the Snippets directory, click Add a new snippet.
Create the snippet:
Name your snippet
hear-about-us.Click Create snippet.
In your new
hear-about-us.liquidsnippet, paste the following code:<style> #how-did-you-hear-about-us--label, #how-did-you-hear-about-us-other--label { font-weight: bold; } select#how-did-you-hear-about-us, input#how-did-you-hear-about-us-other { width: 100%; padding: 8px 10px 8px 10px; line-height: 1.2; } #how-did-you-hear-about-us, #how-did-you-hear-about-us-other, #how-did-you-hear-about-us--label, #how-did-you-hear-about-us--error, #how-did-you-hear-about-us-other--label, #how-did-you-hear-about-us-other--error { display:block; margin-bottom: 5px; } #how-did-you-hear-about-us-other.error, #how-did-you-hear-about-us.error { border: 2px solid {{ settings.hau_error_color }}; } #how-did-you-hear-about-us--error, #how-did-you-hear-about-us-other--error { color: {{ settings.hau_error_color }}; } </style> <div> <p> <label id="how-did-you-hear-about-us--label" for="how-did-you-hear-about-us">How did you hear about us?</label> <span id="how-did-you-hear-about-us--error" style="display:none">{{ settings.hau_error_message }}</span> <select id="how-did-you-hear-about-us" name="attributes[how-did-you-hear-about-us]"> <option value=""{% if cart.attributes.how-did-you-hear-about-us == "" %} selected{% endif %}>Please make a selection</option> {% assign optionsArray = settings.hau_form_options | split: ',' %} {% for o in optionsArray %} {% assign option = o | strip %} <option value="{{ option }}"{% if cart.attributes.how-did-you-hear-about-us == option %} selected{% endif %}>{{ option }}</option> {% endfor %} <option value="Other"{% if cart.attributes.how-did-you-hear-about-us == "Other" %} selected{% endif %}>Other</option> </select> </p> <p id="otherFormWrapper" style="{% unless cart.attributes.how-did-you-hear-about-us == 'Other' %}display:none{% endunless %}"> <label id="how-did-you-hear-about-us-other--label" for="how-did-you-hear-about-us-other">Other</label> <span id="how-did-you-hear-about-us-other--error" style="display:none">{{ settings.hau_error_message_other }}</span> <input id="how-did-you-hear-about-us-other" type="text" name="attributes[how-did-you-hear-about-us-other]" value="{{ cart.attributes.how-did-you-hear-about-us-other }}"/> </p> </div> <script> (function() { document.addEventListener("DOMContentLoaded", initForm); document.addEventListener("shopify:section:load", initForm); function initForm(){ var formElement = document.querySelector('#how-did-you-hear-about-us'); var formError = document.querySelector('#how-did-you-hear-about-us--error'); var otherFormElement = document.querySelector('#how-did-you-hear-about-us-other'); var otherFormError = document.querySelector('#how-did-you-hear-about-us-other--error'); var otherFormWrapper = document.querySelector('#otherFormWrapper'); var checkoutButtons = document.querySelectorAll('[name="checkout"], [name="goto_pp"], [name="goto_gc"]'); function showOrHideForm(){ if (formElement.value == 'Other'){ otherFormWrapper.style.display = ''; } else { otherFormWrapper.style.display = 'none'; } } function checkFormElement(){ if (formElement.value.length == 0){ formElement.classList.add('error'); formError.style.display = ''; } else { if (formElement.classList.contains('error')){ formElement.classList.remove('error'); formError.style.display = 'none'; } } } function checkOtherFormElement(){ if (otherFormElement.value.length == 0){ otherFormElement.classList.add('error'); otherFormError.style.display = ''; } else { if (otherFormElement.classList.contains('error')){ otherFormElement.classList.remove('error'); otherFormError.style.display = 'none'; } } } otherFormElement.addEventListener("input", function() { {% if settings.hau_form_validation %} checkOtherFormElement(); {% endif %} }); formElement.addEventListener("change", function() { showOrHideForm(); {% if settings.hau_form_validation %} checkFormElement(); {% endif %} }); checkoutButtons.forEach(function(element){ element.addEventListener("click", function(evt) { {% if settings.hau_form_validation %} var validated = true; if (formElement.value.length == 0){ checkFormElement(); validated = false; } if (formElement.value == 'Other'){ if (otherFormElement.value.length == 0){ checkOtherFormElement(); validated = false; } } if (!validated) { evt.preventDefault(); evt.stopPropagation(); } {% endif %} }); }); } })() </script>Click Save.
ÎÄÕÂÄÚÈÝȪԴ£ºShopifyÉÌ»§¹Ù·½ÍøÕ¾
- 1º£ÄÚÌú·ÔËÊä
- 2ϺƤÂô³¡ÐÅÓÿ¨·ÖÆÚ³£¼ûÎÊÌâ
- 3Facebook¹ã¸æ¸ÃÔõôÓÅ»¯£¿£¿£¿£¿£¿£¿£¿£¿
- 4Ó¢¹ú¹«Ë¾ÄêÉóµÍ¼ÛÊðÀíµÄÏÝÚå
- 5ÔõÑùÔÚOzonƽ̨Ìí¼ÓÐÂÉÌÆ·£¿£¿£¿£¿£¿£¿£¿£¿
- 6Ôõô×ö¼ÈÄÜÍê³ÉÍË»õÓÖ¿ÉÒÔ±£»£»£»£»£»£»£»£»¤µêËÁ²»ÊÜÓ°Ï죿£¿£¿£¿£¿£¿£¿£¿
- 7¶Ø»ÍÍøÆ½Ì¨Éú³¤Ìصã
- 8ǰհ£¡2019 eBay¼ÒµçÏúÊÛʱ¿Ì±í¼°Ê®´óÈÈÏúÆ·
- 9ÔõÑù½¨ÉèFacebookÏàËÆÊÜÖÚ£¿£¿£¿£¿£¿£¿£¿£¿
- 10ÑÇÂíÑ·Òªº¦´ÊËÑË÷ÅÅÃû¡¢ÍÚ¾òÆÊÎö¹¤¾ß´óÈ«