Untitled

 avatar
webwizards
plain_text
a month ago
1.1 kB
3
Indexable
add_filter('b2bking_skip_price_modifications', function($skip, $product, $price) {
    if ($skip) {
        return $skip;
    }

    if (!is_object($product) || !method_exists($product, 'get_id')) {
        return $skip;
    }

    if ($product->get_type() === 'bundle') {
        return true;
    }

    if (class_exists('WC_PB_Product_Prices')
        && property_exists('WC_PB_Product_Prices', 'bundled_item')
        && !empty(WC_PB_Product_Prices::$bundled_item)) {
        return true;
    }
	
    if (function_exists('WC') && WC()->cart) {
        foreach (WC()->cart->get_cart() as $cart_item) {
            $pid = isset($cart_item['product_id']) ? $cart_item['product_id'] : 0;
            $vid = isset($cart_item['variation_id']) ? $cart_item['variation_id'] : 0;
            if ($product->get_id() === $pid || $product->get_id() === $vid) {
                if (isset($cart_item['bundled_by']) || isset($cart_item['woosb_parent_id'])) {
                    return true;
                }
            }
        }
    }

    return $skip;
}, 10, 3);
Editor is loading...
Leave a Comment