Last active
February 2, 2022 14:54
-
-
Save somewherewarm-snippets/ebe4aaf89b99e43ddd16900c406dbb4e to your computer and use it in GitHub Desktop.
Use this snippet to display validation notices before clicking the place order button.
This file contains 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
<?php | |
/** | |
* Plugin Name: WooCommerce Conditional Shipping and Payments - Display notices dynamically | |
* Plugin URI: https://woocommerce.com/products/conditional-shipping-and-payments/ | |
* Description: Use this snippet to display validation notices before clicking the place order button. | |
* Version: 1.0 | |
* Author: WooCommerce | |
* Author URI: https://woocommerce.com/ | |
* Developer: Jason Kytros | |
* | |
* | |
* Copyright: © 2021 Automattic | |
* License: GNU General Public License v3.0 | |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html | |
*/ | |
add_filter( 'woocommerce_csp_validate_shipping_method_on_update_order_review', '__return_true' ); | |
add_filter( 'woocommerce_csp_validate_payment_gateway_on_update_order_review', '__return_true' ); | |
add_filter( 'woocommerce_csp_validate_shipping_destination_on_update_order_review', '__return_true' ); | |
add_action( 'wp_footer', 'sw_force_checkout_update', 0 ); | |
function sw_force_checkout_update() { | |
?><script type="text/javascript"> | |
jQuery( 'body' ).on( 'init_checkout', function() { | |
jQuery( 'form.checkout' ).trigger( 'update' ); | |
} ); | |
</script><?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an ideal solution for our checkout page, but when triggered the right column area that contains the payment methods, purchase items refreshes over and over. Is there anyway to prevent this?