Understanding form.posted_successfully

Highlighted
New Member
1 0 0

Could someone explain exactly how the form.posted_successfully function works?


I am trying to trigger a register user event, however when clicking on “submit”, I am unable to verify that the form was indeed successfully submitted. For example, I tried adding the following code snippet within the relevant form in customers/register.liquid:


{%- if form.posted_successfully? -%}
<script>console.log("check if submitted");</script>
{%- endif -%}

 

However, nothing happened when I was added as a user since I couldn’t see a message in the console. Could you please guide me as to how the output of this function should look like? Or alternatively, how to trigger an event on the client’s side once a user was successfully added (server side).

0 Likes
Highlighted
Shopify Partner
455 80 103

Did you put that code inside form ? It should work, it will not work if you put it outside of {% form .... %}

Author: Hovhannes Sargsyan (aka sarhov).
An individual web developer focused on Shopify development.
Need more help? Feel free to send me a direct message or drop an email shopify@sarhov.com

Website: https://sarhov.com  
Email: shopify@sarhov.com
Skype: @sarhov
Messenger: @sarhov
Telegram: @sarhov
0 Likes
Highlighted

the logic would be:

if current_url contains

?customer_posted=true

then success == true

so just add ?customer_posted=true onto your url to see what customer will see / test with

 

this doesn't appear to be working 100% of the time for me since captch was introduced - client reported to me
however after having a play around and it seems like it does work after captcha but only if the email is valid and not already added

just test at end with valid email

 

★★★ Need help setting up your Shopify store? Hire me here: https://liquify.design ★★
0 Likes