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 jrick1229/542dfbaefb75e57f23cdcfa36e61c254 to your computer and use it in GitHub Desktop.
Save jrick1229/542dfbaefb75e57f23cdcfa36e61c254 to your computer and use it in GitHub Desktop.
Notice in cart that all shipping options may not show until address is entered in during checkout.
<?php
add_action( 'woocommerce_cart_totals_before_shipping', 'local_pickup_order_comment_validation' );
function local_pickup_order_comment_validation() {
$chosen_shipping = WC()->session->get( 'chosen_shipping_methods' )[0];
$chosen_shipping = explode(':', $chosen_shipping);
if ( $chosen_shipping[0] == 'local_pickup' ){
echo '<p style="font-weight:bold;border:1px solid #000;padding:4px;">Address must be entered into checkout for more shipping options.</p>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment