Last active
November 13, 2018 07:26
-
-
Save varun-pluginhive/930abedc8acf3718a6ac8aceb07a503d to your computer and use it in GitHub Desktop.
Snippet to display error message on woocommerce checkout depending on Specified criteria. PluginHive Plugins : https://www.pluginhive.com/plugins/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Snippet to change display error message on checkout depending on Specified criteria. | |
| * Created at : 10 Nov 2018 | |
| * Updated at : 13 Nov 2018 | |
| * PluginHive Plugins : https://www.pluginhive.com/plugins/ | |
| * Gist Link : https://gist.github.com/varun-pluginhive/930abedc8acf3718a6ac8aceb07a503d | |
| */ | |
| add_action( 'woocommerce_checkout_process', function(){ | |
| $shipping_method = "table_rate:12:2"; // Shipping method value | |
| $message = " Access Point Shipping method requires access point. Please select access point from Dropdown or select a different."; // Error Message | |
| if( ! empty($_POST['shipping_method']) && is_array($_POST['shipping_method']) ) { | |
| $selected_shipping_method = current($_POST['shipping_method']); | |
| if( trim($selected_shipping_method) == trim($shipping_method) && empty($_POST['shipping_accesspoint']) ){ | |
| wc_add_notice( $message, 'error' ); | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment