Skip to content
Advertisement

Get data from apply_filters(‘prefix_xml_feeds_productname_variant’) function in WooCommerce

I’m totally new to WordPress and WooCommerce, so apologies for the poor explanation.

I have this code:

JavaScript

And need to display $vars->ID in my function:

So I got:

JavaScript

How can I access $vars variable value in my callback function?

Advertisement

Answer

As you can see apply_filters( 'prefix_xml_feeds_productname_variant', $text, $product_item->ID, $vars->ID ); contains 3 parameters

So you could use it like

JavaScript

More information: https://docs.woocommerce.com/document/introduction-to-hooks-actions-and-filters/

Using filter hooks

Filter hooks are called throughout are code using apply_filter( 'filter_name', $variable );. To manipulate the passed variable, you can do something like the following:

JavaScript

With filters, you must return a value.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement