This topic has 6 replies, 2 voices, and was last updated 6 years, 7 months ago ago by Rose Tyler
I put the following code in the child function.php and it did not work. I put the same code in the main theme function.php and it worked perfectly …
Please advise
add_action('woocommerce_check_cart_items','check_cart_weight');
function check_cart_weight(){
global $woocommerce;
$weight = $woocommerce->cart->cart_contents_weight;
if( $weight > 30 ){
wc_add_notice( sprintf( __( 'You have %sKg weight and we allow only 30Kg of weight per order.', 'woocommerce' ), $weight ), 'error' );
}
}
Hello,
Have you activated the child theme on site (Appearance > Themes)?
Try to check if this function does not work at all from child theme, you may just echo ‘some text’; in the function to see if it works. If so then it could be wc_add_notice function causes the problem and try to add next strings
add_action('wp_ajax_add_transfer', 'check_cart_weight');
add_action('wp_ajax_nopriv_add_transfer', 'check_cart_weight');
If the problem woun’t be solved, provide temporary wp-admin access and describe in more details how to recreate (what dares to do to see how it works).
Regards
I have tried to echo out in the child theme and it still does not work. You will find access below to the admin section of the
On your site, the active theme is the parent theme https://prnt.sc/j90esu
If you make changes in the child theme and want to see an effect of changes, you need to activate the child theme on site.
Regards
You are right. That was a very basic error on our part and we are very sorry for taking your time with this matter. Thank you for spotting our mistake.
You’re welcome!
Have a nice day.
Regards
You must be logged in to reply to this topic.Log in/Sign up