Php “显示”;“缺货”;商业中的产品变化
我想对我的网站做一些修改,但由于某种原因,我可以得到它。我尝试使用此函数,发现: 函数看起来像返回Php “显示”;“缺货”;商业中的产品变化,php,wordpress,function,woocommerce,variations,Php,Wordpress,Function,Woocommerce,Variations,我想对我的网站做一些修改,但由于某种原因,我可以得到它。我尝试使用此函数,发现: 函数看起来像返回 return $term_name .= ' - ' . $stock_status; 一直如此。有什么帮助吗?从我的问题预览可以看到。谢谢 编辑:这是单选按钮插件中的代码,其中将变体打印为单选按钮: <td class="value"> <?php if ( ! empty( $o
return $term_name .= ' - ' . $stock_status;
一直如此。有什么帮助吗?从我的问题预览可以看到。谢谢
编辑:这是单选按钮插件中的代码,其中将变体打印为单选按钮:
<td class="value">
<?php
if ( ! empty( $options ) ) {
if ( taxonomy_exists( $name ) ) {
// Get terms if this is a taxonomy - ordered. We need the names too.
$terms = wc_get_product_terms( $product->get_id(), $name, array( 'fields' => 'all' ) );
foreach ( $terms as $term ) {
if ( ! in_array( $term->slug, $options ) ) {
continue;
}
print_attribute_radio( $checked_value, $term->slug, $term->name, $sanitized_name );
}
} else {
foreach ( $options as $option ) {
print_attribute_radio( $checked_value, $option, $option, $sanitized_name );
}
}
}
echo end( $attribute_keys ) === $name ?
apply_filters( 'woocommerce_reset_variations_link', '<a
class="reset_variations" href="#">' . __( 'Clear', 'woocommerce' ) . '</a>'
) : '';
?>
</td>
可能需要更新那里的内容才能正确显示?请改为这样做
if( $stock_qty>0 )
//return $term_name .= ' - ' . $stock_status . ' ('.$stock_qty.')';
return $term_name;
else
//return $term_name .= ' - ' . $stock_status;
return $term_name .= ' - Out Of Stock';
<td class="value">
<?php
if ( ! empty( $options ) ) {
if ( taxonomy_exists( $name ) ) {
// Get terms if this is a taxonomy - ordered. We need the names too.
$terms = wc_get_product_terms( $product->get_id(), $name, array( 'fields' => 'all' ) );
foreach ( $terms as $term ) {
if ( ! in_array( $term->slug, $options ) ) {
continue;
}
print_attribute_radio( $checked_value, $term->slug, $term->name, $sanitized_name );
}
} else {
foreach ( $options as $option ) {
print_attribute_radio( $checked_value, $option, $option, $sanitized_name );
}
}
}
echo end( $attribute_keys ) === $name ?
apply_filters( 'woocommerce_reset_variations_link', '<a
class="reset_variations" href="#">' . __( 'Clear', 'woocommerce' ) . '</a>'
) : '';
?>
</td>
if( $stock_qty>0 )
//return $term_name .= ' - ' . $stock_status . ' ('.$stock_qty.')';
return $term_name;
else
//return $term_name .= ' - ' . $stock_status;
return $term_name .= ' - Out Of Stock';