0

I'm using this plugin to customize order statuses in Woocommerce: Woocommerce Order Status Manager

In documentation it says I translate order status name using the following filter:

wc_order_status_manager_order_status_name

Indeed, in plugin source there are these lines:

public function get_name() {

    /**
     * Filter the name
     *
     * @since 1.3.0
     * @param string $name The order status name
     * @param string $slug The order status slug
     */
    return apply_filters( 'wc_order_status_manager_order_status_name', $this->name, $this->slug );
}

In my theme's functions.php I added the following code:

function af_change_shipped_status_name($name, $slug){
if ('shipped' == $slug){
    $name = __('Shipped', 'mythemetextdomain');
}   
return $name;
}

add_filter( 'wc_order_status_manager_order_status_name', 'af_change_shipped_status_name', 10, 2 );

But it's not working.

Were am I wrong?

2

Recheck your filter code closely. You are modifying $name but returning $status_name which is undefined. If you had debugging enabled, you should have seen the debug message telling you that $status_name is an undefined variable

Simply change

return $status_name;

to

return $name;
3
  • Hi Pieter, I'm sorry I mess up with variable names when inserting the code here in the question. Problem is that even returning the right variable, filter is still not working. PS: should I edit the question with the right variable or not?
    – bluantinoo
    Jan 5 '16 at 11:22
  • Have you tried changing the priority of 10 to something like 11 or 999, and are your values what you expect them to be. Do var_dump($name)and var_dump($slug) to check your values. If this does not help, file an edit with all updated info Jan 6 '16 at 4:30
  • I tried changing filter priority just like you suggested, but it's not translating. How to var_dump in a filter function?
    – bluantinoo
    Jan 10 '16 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.