WooCommerce类别和区域特定服务费

时间:2017-05-30 08:04:13

标签: woocommerce

我找到了WooCommerce的这个片段来增加服务费。

    // Add Service Fee to Category
function woo_add_cart_fee() {

$category_ID = '23';
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) {
        // 23 is the ID of the category for which we want to remove the payment gateway
        if($term->term_id == $category_ID){
         $excost = 6;
         }
         }
        $woocommerce->cart->add_fee('Service Fee', $excost, $taxable = false, $tax_class = '');
}
}
add_action( 'woocommerce_cart_calculate_fees', 'woo_add_cart_fee' );

如何仅向某些区域添加服务费?

如果购物车金额超过250美元,怎么可以忽略呢

0 个答案:

没有答案