I have the function below in the woocommerce xero plugin.

   /**
     * @return string
     */
    public function get_name() {
        return apply_filters( 'woocommerce_xero_contact_name', $this->name, $this );
    }

I need to change

'woocommerce_xero_contact_name', $this->name, $this );

to this

'woocommerce_xero_contact_name', $this->billing_company, $this );

when I tried to write a function for my functions.php I keep getting Error: “Using $this when not in object context” which I don’t understand.

my function looks like this at the moment;

public function xero_contact_name_1( $this ) {


    return $this->billing_company;
}
add_filter( 'woocommerce_xero_contact_name', 'xero_contact_name_1' );

Any ideas what I’m doing wrong?

Thanks

Read more here: Woocommerce Xero function not working – "Error: "Using $this…"


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: