0

I want to be able to use the product variables across all templates. Where should I store them? In Woocommerce templates folder? Example:

$productTitle = $product->get_name(); $productSlug = $product->get_slug();

I need to be able to echo these variables and I don't want to declare them more than once. <h3> $productTitle </h3>

What's the better and cleaner way of doing it?

Thank you

0

Is there a particular reason why you would like to "store" them? If not, you can simply do it like this:

<h3><?php echo esc_html( $product->get_name() ); ?></h3>
| improve this answer | |

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.