最小变动价格,我是一个初学者想学习Wordpress和具有可变产品价格:获取WooCommerce
- 鳕鱼250卢比
- 在线200卢比
我想在我的主题functions.php
中使用最低价格。
我将如何获取或获取最小值?
我想在下面的代码使用方法:
function filter_gateways($gateways){
$payment_NAME = 'cod'; //
$min_variation_price = ''; <--------------- minimum variation price
global $woocommerce;
foreach ($woocommerce->cart->cart_contents as $key => $values) {
// Get the terms, i.e. category list using the ID of the product
$terms = get_the_terms($values['product_id'], 'product_cat');
// Because a product can have multiple categories, we need to iterate through the list of the products category for a match
foreach ($terms as $term) {
// 20 is the ID of the category for which we want to remove the payment gateway
if($term->term_id == $min_variation_price){
unset($gateways[$payment_NAME]);
// If you want to remove another payment gateway, add it here i.e. unset($gateways['cod']);
break;
}
break;
}
}
return $gateways;
}
谢谢先生的回答很好的解释,但我不想与产品类别匹配,我只是想如果选择最低价格只是取消鳕鱼网关 – Peace