如何在尺寸属性Woocommerce旁边添加库存量?

时间:2020-03-19 18:26:48

标签: php wordpress woocommerce

我正在尝试在尺寸调整块内显示缺货消息。我使用的是儿童主题,但似乎无法弄清楚如何替换库存(售罄时)。

Visualisation of what I am trying to achieve.

(在上图中,该产品并未售罄,而只是作为演示)

到目前为止我尝试过的是:

add_filter( 'woocommerce_attribute_label', 'custom_attribute_label', 10, 3 );

function custom_attribute_label( $label, $name, $product ) {
$taxonomy = 'pa_'.$name;


if( $taxonomy == 'pa_maat' )
    $label .= '<div class="custom-label">' . __('woocommerce-variation-availability', 'woocommerce') . '</div>';

return $label;}

现在,我的商品尺寸属性为pa_size,并且库存量来自“库存量”类或“ woocommerce差异库存量”。另外,如果可能的话,我只想在实际售罄的尺寸后面添加“无货”。

我们非常感谢您的帮助。

0 个答案:

没有答案