我数据库中的每个产品都有一个“pa_producator”属性,我想要以下内容:当 pa_producator 等于“Bosch”时,仅对该产品应用 10% 的折扣,而不是对整个购物车。这可能吗?到目前为止,我只有以下代码:
add_action('woocommerce_before_cart_table', 'discount_producer');
function discount_producer( ) {
global $woocommerce;
$test = $woocommerce->cart->get_cart();
foreach($test as $product) {
$test = get_the_terms( $product['product_id'], 'pa_producator');
$producator = $test[0]->name;
}
}
我如何为这些产品申请折扣?