dynamically require phone number or company name

Hey guys,

We currently don't require phone number or company name at checkout. We'll be sending some wholesale customers through checkout soon, but want to require phone/company. I imagined passing a custom field through as a switch, but not sure which event to tie in to to dynamically require each field. I also searched through the first 5 pages of the forum search results for help, but couldn't find anything useful.

Thank you!
  • fc_adamfc_adam FoxyCart Team

    Thanks for posting! It is possible to dynamically require otherwise optional fields with javascript on your checkout template. We have an example of requiring the shipping phone field on our wiki here: https://wiki.foxycart.com/v/2.0/snippets/dynamically_require_phone - that should hopefully give you an idea of how it would apply for the company field too.

    The snippet is based on the country selection, so it needs to update whenever the shipping country changes. As you're looking to do it based on a custom session attribute - you will be able to simplify it a little to only need to make the fields required if that attribute is present, rather than needing to switch between the two.

    Let us know if you need any help with customising that snippet to do what you're after.
  • Thanks @fc_adam! I knew I had seen something like that somewhere. I appreciate it!

Sign In or Register to comment.