Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
This code doesn't work. Any ideas?
We need to add subscribe form on website to create new customers by phone number only.
{%- form 'create_customer', class: 'form', id: 'customer_subscribe_form' -%}
<div class="fieldset">
{%- capture label -%}{{ 'general.subscribe.phone' | t }}{%- endcapture -%}
{%- render 'input', name: 'customer[phone]', label: label, type: 'tel', required: true, autocomplete: 'tel' -%}
</div>
<div class="accepts-marketing">
<input type="hidden" name="customer[accepts_marketing]" value="false" />
<input type="checkbox" name="customer[accepts_marketing_sms]" id="accepts-marketing-sms" />
<label for="accepts-marketing-sms">{{ 'general.subscribe.agree_sms_marketing' | t }}</label>
</div>
<div class="fieldset-with-submit">
<button type="submit" class="button button--primary">
{{ 'general.subscribe.subscribe' | t }}
</button>
</div>
{%- endform -%}
We use this code to add user as subscriber by email. But we want to change it to Phone Nubmer.
{%- form 'customer', id: newsletter_form_id, class: 'form' -%}
{%- if form.posted_successfully? -%}
{%- assign success_message = 'general.newsletter.subscribed_successfully' | t -%}
{%- render 'banner', content: success_message, status: 'success' -%}
{%- else -%}
{%- if form.errors -%}
{%- capture error_message -%}{{ form.errors.translated_fields['email'] }} {{ form.errors.messages['email'] }}{%- endcapture -%}
{%- render 'banner', content: error_message, status: 'error' -%}
{%- endif -%}
<input type="hidden" name="contact[tags]" value="ONECLICKBUY">
<div class="fieldset-with-submit">
{%- capture label -%}{{ 'general.newsletter.email' | t }}{%- endcapture -%}
{%- render 'input', name: 'contact[email]', label: label, type: 'email', required: true, autocomplete: 'email', enterkeyhint: 'send' -%}
<button type="submit" class="button button--xl" is="custom-button"><div>
<div class="text-with-icon justify-center"> BUY WITH HELP<svg role="presentation" fill="none" focusable="false" stroke-width="2" width="24" height="24" class="icon icon-picto-operator" viewBox="0 0 24 24">
<path d="M21.919 14.589a1.38 1.38 0 0 0 .492-.432c.883-1.26-2.716-4.315-2.971-6.151-.69-4.967-4.59-6.72-8.932-6.72-5.85 0-9.222 3-9.222 9 0 4.104 1.071 5.479 2.367 7.575.711 1.149 1.012 2.493 1.008 3.844-.002.76-.003 1.522-.003 2.283h10.316V21c.095-.765.777-1.277 1.546-1.277h.846a2.572 2.572 0 0 0 2.571-2.572v-2.374l1.346-.034c.22 0 .439-.052.634-.154h.002Z" fill="currentColor" fill-opacity=".12"></path>
<path d="M4.658 22.714v-.997c.005-1.358-.295-2.709-1.012-3.864-1.29-2.092-2.36-3.47-2.36-7.567 0-3.808 1.357-6.408 3.847-7.8M11.146 8.578V1.286M11.146 15.429c2.195 0 3.429-1.235 3.429-3.429s-1.234-3.429-3.429-3.429c-2.194 0-3.428 1.235-3.428 3.429s1.234 3.429 3.428 3.429v0Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M12 15.369c1.714 1.714 5.143 3.488 9.429 3.488" stroke="currentColor" stroke-linecap="round"></path>
<path d="m19.937 14.777 1.346-.034a1.378 1.378 0 0 0 1.128-.586c.883-1.26-2.716-4.315-2.971-6.151-.403-2.89-1.891-4.692-3.922-5.695M14.974 22.714v-.857" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path>
</svg></div></div><span class="button__loader">
<span></span>
</span></button>
</div>
{%- endif -%}
{%- if section.settings.subtext != blank -%}
<p class="text-xs text-subdued">{{ section.settings.subtext | escape }}</p>
{%- endif -%}
{%- endform -%}
The code you provided seems to be a Liquid code snippet for creating a customer subscribe form with a phone number input and an SMS marketing checkbox. However, it appears that the formatting is not correct in the text you shared, which could be causing the issue.
Here's the properly formatted code snippet:
{%- form 'create_customer', class: 'form', id: 'customer_subscribe_form' -%}
<div class="fieldset">
{%- capture label -%}{{ 'general.subscribe.phone' | t }}{%- endcapture -%}
{%- render 'input', name: 'customer[phone]', label: label, type: 'tel', required: true, autocomplete: 'tel' -%}
</div>
<div class="accepts-marketing">
<input type="hidden" name="customer[accepts_marketing]" value="false" />
<input type="checkbox" name="customer[accepts_marketing_sms]" id="accepts-marketing-sms" />
<label for="accepts-marketing-sms">{{ 'general.subscribe.agree_sms_marketing' | t }}</label>
</div>
<div class="fieldset-with-submit">
<button type="submit" class="button button--primary">
{{ 'general.subscribe.subscribe' | t }}
</button>
</div>
{%- endform -%}
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025