Woocomerce some hooks are not firing
-
Hi
I am using woocommerce Version 4.8.0 with my custom theme and WordPress 5.6.4, I have used some hooks in functions.php for customization. Earlier it was working fine but from few days, some hooks are not showing the changes I have done.
Below is the hook I used to change the formatted order total text, but now it’s now working
add_filter( 'woocommerce_get_formatted_order_total', 'change_emails_formatted_order_total', 10, 2 ); function change_emails_formatted_order_total( $formatted_total, $order ) { error_log('woocommerce_get_formatted_order_total Triggered'); if(is_wc_endpoint_url()){ $formatted_total = wc_price( $order->get_total(), array( 'currency' => $order->get_currency() ) ) . ' (' . __("inkl. 7.7% MwSt. ", "woocommerce"). get_woocommerce_currency_symbol().' '.$order->get_total_tax().')'; } else { $formatted_total = wc_price( $order->get_total(), array( 'currency' => $order->get_currency() ) ) . '<span class="cls_tax"> (' . __("inkl. 7.7% MwSt. ", "woocommerce"). get_woocommerce_currency_symbol().' '.$order->get_total_tax().')</span>'; } return $formatted_total; }
One more function, this was also working properly, when I implemented this, but not working now.
add_action( 'woocommerce_add_cart_item_data', 'make_cart_empty', 10, 2 ); function make_cart_empty() { global $woocommerce; if ( sizeof( WC()->cart->get_cart() ) > 0 ) { foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { $product = $cart_item['data']; $product_id = $cart_item['product_id']; $prtype = get_field('produkt_design',$product_id); } } if($sessionid == 6 && $prtype != 'test'){ if( ! WC()->cart->is_empty()){ WC()->cart->empty_cart(); //wc_print_notice( '', 'notice' ); } } elseif($sessionid == 29 && $prtype != 'test1'){ if( ! WC()->cart->is_empty()){ WC()->cart->empty_cart(); } } elseif($sessionid == 34 && $prtype != 'test2'){ if( ! WC()->cart->is_empty()){ WC()->cart->empty_cart(); } } }
Both the functions are not working, so it seems there is some issue in hooks firing.
Could you please tell me how can I resolve this issue and also how can I make sure that hooks are triggered or not.Thanks
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Woocomerce some hooks are not firing’ is closed to new replies.