Last active
December 20, 2023 15:35
-
-
Save xadapter/4844a611b2cc3458a3c1856aa5113842 to your computer and use it in GitHub Desktop.
Snippet to customize the “There are no shipping methods available..” message found on the WooCommerce cart or checkout page based on cart total weight. Supports PluginHive Shipping Plugins: https://www.pluginhive.com/product-category/woocommerce-plugin/woocommerce-shipping/
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
// For Cart Page. | |
add_filter( 'woocommerce_no_shipping_available_html', 'wf_customize_default_message_if_weght_exceeds', 10, 1 ); | |
// For Checkout page | |
add_filter( 'woocommerce_cart_no_shipping_available_html', 'wf_customize_default_message_if_weght_exceeds', 10, 1 ); | |
function wf_customize_default_message_if_weght_exceeds( $default_msg ) { | |
$weight_limit = 50; | |
$custom_msg = "Call us for quotation - 1-800-XXX-XXXX"; | |
global $woocommerce; | |
$cart_weight = $woocommerce->cart->get_cart_contents_weight(); | |
if ( $cart_weight > $weight_limit ) { | |
if( empty( $custom_msg ) ) { | |
return $default_msg; | |
} | |
return $custom_msg; | |
} | |
return $default_msg; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, Still working in woocommerce 3.6.4, and WP 5.2.2