admin管理员组文章数量:1323723
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
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
Share Improve this question asked Sep 12, 2020 at 10:59 Carla GoncalvesCarla Goncalves 11 bronze badge1 Answer
Reset to default 0Is 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>
本文标签: Best way to declare product variables in woocommerce theme development
版权声明:本文标题:Best way to declare product variables in woocommerce theme development? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742123427a2421829.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论