WooCommerce Product Bundles
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
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); add_filter( 'woocommerce_hidden_order_itemmeta', function ( $keys ) { $keys[] = '_stamp'; return $keys; }); |