checkout-as-guest click event at checkout

Hey guys,

Would love to have (or know if it already exists) a hook for the checkout-as-guest button click event. Can't find anything that fires.

I expected this to run:
FC.client.on('customer-email-update.done', function() {
jQuery('[data-fc-id="checkout-as-guest"]').on('click', showMoreSteps);
});

but it doesn't trigger.

Thanks as always,
Jacob
Tagged:
Comments
  • fc_adamfc_adam FoxyCart Team
    @jacobdubail,

    You can simply bind your custom click event on document.ready - it doesn't need to be within our existing event system. So you can just do:
    jQuery(document).ready(function() {
    jQuery('body').on('click', '[data-fc-id="checkout-as-guest"]', showMoreSteps);
    });
    If you're dynamically showing more markup though if a user is checking out as a guest, I'd recommend handling the display of the fields within the Twig templates, and then just triggering the re-render as needed via javascript. That will be the most reliable way to approach it.
  • Thanks @fc_adam,
    I'd recommend handling the display of the fields within the Twig templates, and then just triggering the re-render as needed via javascript.
    We're not showing more fields only for guest checkout, but basically hiding all steps except for login until someone logs in, hits the checkout as guest, or our own little button. So I don't think I can handle all of that via twig. Maybe I'm missing something?
  • fc_adamfc_adam FoxyCart Team
    edited January 10
    @jacobdubail,

    Ah ok thanks for clarifying. That would be achievable with Twig, but you'd have to customise the whole template. You can handle it with javascript, that should be fine.
Sign In or Register to comment.