Accessing Product Properties
-
I am trying to use the following filter to customize the html used to display products in the Product By Tag block.
add_filter( ‘woocommerce_blocks_product_grid_item_html’, ‘customise_product_display’, 10, 3 );
function customise_product_display( $html, $data, $product ){
// filter…
}I need to access the $product object to determine what changes, if any, need making.
When I access $product->description, for example, I get the following error displayed:
Product properties should not be accessed directly.
How are you meant to access this object then, that has been supplied as an argument to this filter?
Also, if I test out the change by amending the $html variable, it does not appear to work.
str_replace(‘Tights’, ‘Hosiery’ , $html);
var_dump($html);The variable still displayed ‘Tights’ and not ‘Hosiery’. I thought this was going to be straight forward to do, but nothing seems to be working with it.
Any help or advice appreciated…
The topic ‘Accessing Product Properties’ is closed to new replies.