Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I have Shopify customer form set up to get emails for our product recommendation quiz.
The issue I'm running into is the inability to run a function or redirect the user when they submit their email through the form (the native functionality is just refreshing the page with a success message)
I need to run the goToCart() function on form submit, and none of these method below work:
{%- form 'customer', class: 'quiz-form', onsubmit:'goToCart();'-%}
<label for="quiz_email_input">Email</label>
<input type="hidden" name="contact[tags]" value="sweatquiz">
<input
type="email"
name="contact[email]"
class="quiz_email_input"
value="{{ form.email }}"
autocorrect="off"
autocapitalize="off"
autocomplete="email"
>
<div class="next_button_background" style="text-align:center;">
<button type="submit" class="next_button" onclick="goToCart();" style="margin-bottom: 10px;">SEE RESULTS</button>
</div>
{%- if form.posted_successfully? -%}
<script>(function(){goToCart();})</script>
{%- endif -%}
{%- endform -%}
Do you have solution?
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025