add_filter( 'wpo_skip_add_to_cart_item', function ( $skip, $item ) {
return isset($item['bundled_by']) ? true : $skip;
}, 10, 2 );
add_filter( 'wpo_is_child_cart_item', function ( $child, $item ) {
return isset($item['bundled_by']) ? true : $child;
}, 10, 2 );
add_filter( 'wpo_search_product_types', function ( $types ) {
$types[] = "bundle";
return $types;
} );
add_filter('wpo_add_configured_products_skip_item', function ($skip, $item_data) {
return isset($item_data['bundled_by']) ? true : $skip;
}, 10, 2);
add_filter('wpo_children_cart_item', function ($children, $item) {
return isset($item['bundled_items']) ? $item['bundled_items'] : $children;
}, 10, 2);
add_filter('wpo_cart_item_is_price_readonly', function ($is_readonly, $item) {
return isset($item['bundled_items']) ? true : $is_readonly;
}, 10, 2);
add_filter('wpo_get_item_by_product', function ($product, $item_data) {
return array_merge($product, array(
'stamp' => isset($item_data['stamp']) ? $item_data['stamp'] : null,
'readonly_price' => isset($item_data['readonly_price']) ? $item_data['readonly_price'] : null,
));
}, 10, 2);
add_filter('wpo_update_cart_loaded_product', function ($loaded_product, $item) {
return array_merge($loaded_product, array(
'stamp' => isset($item['stamp']) ? $item['stamp'] : null,
'readonly_price' => isset($item['readonly_price']) ? $item['readonly_price'] : null,
));
}, 10, 2);
add_filter('wpo_update_cart_cart_item_meta', function ($cart_item_meta, $item) {
return array_merge($cart_item_meta, array(
'stamp' => isset($item['stamp']) ? $item['stamp'] : null,
'readonly_price' => isset($item['readonly_price']) ? $item['readonly_price'] : null,
));
}, 10, 2);
add_filter('wpo_add_configured_products_item_data', function ($item_data, $cart_item_data, $cart_item_key, $wc_product) {
if ( isset( $cart_item_data['bundled_items'] ) ) {
$readonly_price = apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $wc_product ), $cart_item_data, $cart_item_key );
if (preg_match('/<\/span>([\d|\.]+)?/i', $readonly_price, $matches)) {
$item_data['readonly_price'] = $matches[1];
}
}
return $item_data;
}, 10, 4);WooCommerce Product Bundles, by SomewhereWarm Print
Created by: Alex Prokaev
Modified on: Fri, 14 Jun, 2019 at 2:16 PM
Did you find it helpful? Yes No
Send feedbackSorry we couldn't be helpful. Help us improve this article with your feedback.