I need to show to my clients a message in Cart and Checkout page on Wordpress. This message should show the weight of the products in cart and tell them the remaining weight
you can use popup maker plugin for display content or form and shortcode also. The plugin provides you popup shortcode. check this link https://wordpress.org/plugins/popup-maker/ Thanks
the following code will display a custom notice in cart and checkout pages displaying the cart total weight and the remaining weight. You will have to set the allowed weight limit in the function.
The code:
add_filter( 'woocommerce_before_cart', 'display_total_weight_notice' );
add_filter( 'woocommerce_before_checkout_form', 'display_total_weight_notice' );
function display_total_weight_notice( $message ) {
// DEFINE the allowed weight limit
$allowed_weight = 3;
$cart_total_weight = WC()->cart->get_cart_contents_weight();
if( $cart_total_weight <= $allowed_weight ) :
wc_print_notice( sprintf(
__( 'Your order has a total weight of %s. The remaining available weight is %s for the current shipping cost' ),
'<strong>' . wc_format_weight($cart_total_weight) . '</strong>',
'<strong>' . wc_format_weight($allowed_weight - $cart_total_weight) . '</strong>'
),'notice' );
endif;
}
Code goes in function.php file of your active child theme (or active theme). Tested and work.