0

I have this filter which works fine from the frontend. The only problem is that I display the div as text in the wordpress backend admin panel.

https://i.stack.imgur.com/jupjS.png

Is there any way to hide that div only in the backend? Or do I have to choose another way to modify the css of each state? How can I do ?

Sorry but I'm new, thanks for any reply.

// Rinomina gli stati degli ordini da frontend
add_filter( 'wc_order_statuses', 'ts_rename_order_status_msg', 20, 1 );
function ts_rename_order_status_msg( $order_statuses ) {
 $order_statuses['wc-completed']       = _x( '<div class="status success">Acquistato</div>', 'Order status', 'woocommerce' ); 
 $order_statuses['wc-processing']      = _x( '<div class="status processing">In Elaborazione</div>', 'Order status', 'woocommerce' );
 $order_statuses['wc-on-hold']         = _x( '<div class="status waiting">In Attesa</div>', 'Order status', 'woocommerce' );
 $order_statuses['wc-pending']         = _x( '<div class="status suspended">Sospeso</div>', 'Order status', 'woocommerce' );    
 return $order_statuses;
}
Snorlax
  • 233
  • 8
  • It shows the HTML because this hook has no intention of changing statuses including HTML, only strings are allowed. By the way, it doesn't matter for CSS which naming is used as a selector so why bother trying to change it – 7uc1f3r May 03 '22 at 06:29
  • I'm trying to change it because I need that div for the frontend, but it also shows up in the backend. – Snorlax May 04 '22 at 00:23
  • Where in the front end? which part? There must be a better/correct way – 7uc1f3r May 04 '22 at 04:22
  • In the frontend I using twig code with elementor pro to show the order status: `{{order.get_status | php ('wc_get_order_status_name')}}` The preceding line of code is the equivalent of `wc_get_order_status_name( $order->get_status() )`. I'm using `wc_get_order_status_name` because if I just return with `$order->get_status();` the state name is not translated. – Snorlax May 04 '22 at 15:42

0 Answers0