Understanding form.posted_successfully

OptiPI
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
sarhov
Shopify Expert
482 85 155

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)
Email: shopify@sarhov.com
Website: https://sarhov.com
Try Shopify free for 14 days,

0 Likes

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
YaketyMatt
Shopify Partner
32 0 3

If you still require assistance with this issue then please visit https://yakety.co.uk and submit a development request.

Matthew Anderson | Shopify Expert | +44 20 3920 8081 |  support@yakety.co.uk |  https://yakety.co.uk | Facebook | Twitter | Instagram
0 Likes
themusaib1
New Member
1 0 0

form successfully ? is returning the sucess message everytime we reload the the page, but it should return only first time when page is loaded after form submission.

How to make it possible to get the success message only once ?

0 Likes