1

我正在尝试根据用户对可变产品的选择来找出一种显示自定义文本的方法。

属性是“定价”,标签是存款——我在添加属性时添加了文本描述。所以我试图在用户选择“存款”时显示此文本

但是我在“content-single-product.php”中使用的代码一直在显示文本,无论是否选择了什么变量。

<?php $my_taxonomy = 'pa_pricing'; 

$terms = wp_get_post_terms( $post->ID, $my_taxonomy ); 

echo term_description($terms[0]->term_id, $my_taxonomy); 
 ?>

我只希望在用户选择定价“存款”后显示文本有人可以帮我吗?

4

2 回答 2

0

I am no expert on php, but as you declare your $my_taxonomy to be the text "pa_pricing"

So, for starters, that should be something like

$my_taxonomy = get_the_terms( $product->id, 'pa_pricing');

That might help you? As for the rest of your question, I'd really like an answer on that one too!

于 2013-11-26T20:23:17.033 回答
0

本教程解释了一种方法:

http://blueskysessions.com/2014/03/31/woocommerce-display-dynamic-content-per-the-selected-product-variation/

海报修改了 variable.php - 可能是插入代码的更好位置。

如果你发现了另一种方法,请在这里分享。

于 2014-06-01T21:21:43.700 回答