【发布时间】:2019-02-20 19:23:57
【问题描述】:
我正在尝试将自定义字段添加到特定类别中的产品的单个产品页面。我遇到了条件逻辑问题。 这是我到目前为止所得到的:
function cfwc_create_custom_field() {
global $product;
$terms = get_the_terms( $product->get_id(), 'product_cat' );
if (in_array("tau-ende", $terms)) {
$args = array(
'id' => 'custom_text_field_title',
'label' => __( 'Custom Text Field Title', 'cfwc' ),
'class' => 'cfwc-custom-field',
'desc_tip' => true,
'description' => __( 'Enter the title of your custom text field.', 'ctwc' ),);
woocommerce_wp_text_input( $args );
}}
该函数有效,但 if 语句无效。有谁知道我做错了什么?
【问题讨论】:
标签: php wordpress woocommerce custom-taxonomy taxonomy-terms