admin管理员组文章数量:1125950
I'm building a template page for my own woocommerce theme.
[ISSUE:] While I call the function woocommerce_template_single_add_to_cart it show the section which contain the html output of the variations' dropwown and the descriptions/prices related on current selected variation. All right, it do the output correctly inside the proper div element, like this:
<div class="single_variation_wrap">
<div class="woocommerce-variation single_variation" style="">
<div class="woocommerce-variation-description">
<p>Option 1 description</p>
</div>
<div class="woocommerce-variation-price">
etc....
I need to separate this section from the dropdown's html output, so I wrote the code to show only the dropdown and it work, but I'm unable to show again the dynamic description and price! Which is the correct function to call in order to show just the variation's description and its price?
Thanks in advance!
I'm building a template page for my own woocommerce theme.
[ISSUE:] While I call the function woocommerce_template_single_add_to_cart it show the section which contain the html output of the variations' dropwown and the descriptions/prices related on current selected variation. All right, it do the output correctly inside the proper div element, like this:
<div class="single_variation_wrap">
<div class="woocommerce-variation single_variation" style="">
<div class="woocommerce-variation-description">
<p>Option 1 description</p>
</div>
<div class="woocommerce-variation-price">
etc....
I need to separate this section from the dropdown's html output, so I wrote the code to show only the dropdown and it work, but I'm unable to show again the dynamic description and price! Which is the correct function to call in order to show just the variation's description and its price?
Thanks in advance!
Share Improve this question asked Dec 7, 2017 at 5:26 Giangel84Giangel84 841 silver badge6 bronze badges 2 |2 Answers
Reset to default 1If you have the variation id, you can use PHP code like this :
$variation = wc_get_product( '14803' );
echo $variation->get_description();
echo $variation->get_price();
Source
$_product = wc_get_product( $product_id );
This displays price: $_product->get_price()
This displays description: $_product->get_variation_description()
本文标签: How to display Woocommerce variations prices and descriptions
版权声明:本文标题:How to display Woocommerce variations prices and descriptions 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736678611a1947310.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
wc_get_product
for showing required data.$_product = wc_get_product( $product_id );
– BlueSuiter Commented Dec 7, 2017 at 5:43