【发布时间】:2021-05-19 13:18:29
【问题描述】:
在我的 WooCommerce 网站上,我设置了每半米出售的面料,下面的代码一切正常:
function conditional_price_suffix( $price, $product ) {
$product_id = $product->is_type('variation') ? $product->get_parent_id() : $product->get_id();
$product_categories = array('half-metre');
if( has_product_categories( $product_categories, $product_id ) )
$price .= ' ' . __('per ½ metre');
return $price;
}
但是,我如何操作代码以添加另一个选项 per “ Quarter-metre” 并输出 “per ¼ metre” 作为后缀。
有什么帮助吗?
【问题讨论】:
标签: php wordpress woocommerce product suffix