/** * Cost of goods compatibility: Zero order item cost for bundled products that belong to statically priced bundles. * * @param double $cost * @param array $item * @param WC_Order $order * @return double */ public static function cost_of_goods_set_order_item_bundled_item_cost($cost, $item, $order) { if (!empty($item['bundled_by'])) { // Find bundle parent. $parent_item = WC_PB_Order::get_bundle_parent($item, $order); $per_product_pricing = !empty($parent_item) && isset($parent_item['per_product_pricing']) ? $parent_item['per_product_pricing'] : get_post_meta($parent_item['product_id'], '_per_product_pricing_active', true); if ($per_product_pricing === 'no') { return 0; } } elseif (!isset($item['bundled_by']) && isset($item['stamp'])) { $per_product_pricing = isset($item['per_product_pricing']) ? $item['per_product_pricing'] : get_post_meta($item['product_id'], '_per_product_pricing_active', true); if ($per_product_pricing === 'yes') { return 0; } } return $cost; }
/** * Used to link bundled order items with the composite container product. * * @param boolean $is_child * @param array $order_item * @param array $composite_item * @param WC_Order $order * @return boolean */ public static function bundled_order_item_is_child_of_composite($is_child, $order_item, $composite_item, $order) { if (!empty($order_item['bundled_by'])) { $parent = WC_PB_Order::get_bundle_parent($order_item, $order); if ($parent && isset($parent['composite_parent']) && $parent['composite_parent'] === $composite_item['composite_cart_key']) { return true; } } return $is_child; }