Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save somewherewarm-snippets/ebe4aaf89b99e43ddd16900c406dbb4e to your computer and use it in GitHub Desktop.
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.
<?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
}
@glenbaird
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment