Preciousomonze / woocommerce-phone-validator

Forces validation of woocommerce phone field on checkout and billing address edit page
https://wordpress.org/plugins/woo-phone-validator
GNU General Public License v3.0
20 stars 11 forks source link

BackEnd Phone # Validation #29

Open Preciousomonze opened 4 years ago

Preciousomonze commented 4 years ago

Hi, Is there any plan to add validation to the 3 back end occurrences of Woo billing phone #: – Edit User – Edit Profile – Edit Order

We have agents that sometimes need to use these screens to create/update customer phone info and ideally they would use the plugin as well.

Thanks for your consideration.

Josh

More info here https://wordpress.org/support/topic/back-end-phone-validation/#post-13383550

Preciousomonze commented 4 years ago

Leaving this here, will probably do it later later later later later 🤡 I hope i remember 👽

JoshLavinsky commented 4 years ago

Hi Code Xplorer, I have built the necessary 2 files that go in the public directory:

I have lightly tested it and seems to work and plan to put it in our production environment this week. Would be great if you would consider merging into your core or at least add the hooks in class-wc-pv.php so I and others can use the plugin but extent to other pages. Happy to answer any questions.

woo_phone_validate_backend.zip

Preciousomonze commented 4 years ago

Nice, thanks for this, oh thought this was a PR, was about telling you to branch from 'rogue-development' I'll see if i can implement this into that branch. 🔥🔥

JoshLavinsky commented 4 years ago

Not sure if you already caught this, In further testing, the changes i made to class-wc-pv.php file line 108 to limit where the plugin loads on front end is incorrect as it doesn't allow the plugin to load woocommerce_after_checkout_validation. Perhaps your "extra custom validation" for checkout could be a separate file/include and loaded in class-wc-pv.php "load plugins" for all front end pages or you could move line 108 to the checkout file and queue up woocommerce_after_checkout_validation after the if statement closes . The main thing is not to load intl-tel-input on pages its not required as its high overhead.

Also on our site we moved phone number to the edit account page from the edit address which is why I was filtering for that on line 108. Perhaps you could add a filter here so people can add/remove pages that they have phone #s on.

Preciousomonze commented 4 years ago

Yes, @JoshLavinsky , i made validation on separate files in my v2.0(not yet launched) I've kept in mind most of these things, that was one reason why i couldn't load the script only in the necessary pages , i think 🤔, not sure anymore. But thanks a lot for all these, i really appreciate.

JoshLavinsky commented 4 years ago

Been running in prod for a while and found some issues with my code and realized I sent you wrong class-wc-pv.php file. Also there is a need to modify frontend.js Line 98: I changed #billing_phone to [id$=billing_phone] to support Woo Admin Edit Order page using "_billing_phone" for the billing phone element. admin_phobe_validation.zip

Preciousomonze commented 4 years ago

I haven't even opened the zip, but thanks.