Craft Posted August 25 Share Posted August 25 Hello, Could someone help me create a hook on the checkout page that prevents the customer from completing the order if he filled out any of these fields (Address 1, City, State, Postal Code, and Phone Number)? 0 Quote Link to comment Share on other sites More sharing options...
WhmTools Posted August 25 Share Posted August 25 You mean prevent them from placing the order if they didn't enter Address 1, City, State, Postal Code, and Phone Number? 0 Quote Link to comment Share on other sites More sharing options...
Craft Posted August 25 Author Share Posted August 25 (edited) 3 hours ago, WhmTools said: You mean prevent them from placing the order if they didn't enter Address 1, City, State, Postal Code, and Phone Number? No, my post is correct. I want the hook to not proceed with an order if the customer fills out any of these fields (Address 1, City, State, Postal Code, and Phone Number). I already hide them by CSS, but some script hackers can still fill out these fields to complete fake orders. Edited August 25 by Craft 0 Quote Link to comment Share on other sites More sharing options...
Solution DennisHermannsen Posted August 25 Solution Share Posted August 25 <?php add_hook('ShoppingCartValidateCheckout', 1, function($vars) { if (!empty($vars['address1']) || !empty($vars['city']) || !empty($vars['postcode']) || !empty($vars['phonenumber'])) { return ['gotcha!']; } }); 0 Quote Link to comment Share on other sites More sharing options...
Craft Posted August 28 Author Share Posted August 28 On 8/26/2024 at 1:32 AM, DennisHermannsen said: <?php add_hook('ShoppingCartValidateCheckout', 1, function($vars) { if (!empty($vars['address1']) || !empty($vars['city']) || !empty($vars['postcode']) || !empty($vars['phonenumber'])) { return ['gotcha!']; } }); Thanks @DennisHermannsen for the hook, it solved my issue 🙂 Can we create the same hook code for the Register page? 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.