add_filter('wpo_update_cart_cart_item_meta', function ($cart_item_meta, $item) { return array_merge($cart_item_meta, array( 'addons' => isset($item['addons']) ? $item['addons'] : null, )); }, 10, 2); add_filter('wpo_update_cart_loaded_product', function ($loaded_product, $item) { return array_merge($loaded_product, array( 'addons' => isset($item['addons']) ? $item['addons'] : null, 'readonly_price' => $item['line_subtotal'] / $item['quantity'], 'readonly_custom_meta_fields_html' => isset($item['addons']) ? wc_get_formatted_cart_item_data($item) : '', )); }, 10, 2); add_filter('wpo_product_calc_line_subtotal', function ($calc, $item) { return isset($item['addons']) && $item['addons'] ? false : $calc; }, 10, 2); add_filter('wpo_get_item_by_product', function ($product, $cart_item_data) { return array_merge($product, array( 'addons' => isset($cart_item_data['addons']) ? $cart_item_data['addons'] : null, 'readonly_price' => $cart_item_data['line_subtotal'] / $cart_item_data['quantity'], )); }, 10, 2); add_filter('wpo_cart_item_is_price_readonly', function ($is_readonly, $cart_item_data) { return isset($cart_item_data['addons']) && $cart_item_data['addons'] ? false : $is_readonly; }, 10, 2); add_filter('woocommerce_get_cart_item_from_session', function ($cart_item, $cart_item_key) { if ( ! empty( $cart_item['cost_updated_manually'] ) && ! empty( $cart_item['addons'] ) ) { $cart_item['data']->set_price($cart_item['wpo_item_cost']); } return $cart_item; }, 1000, 2);
WooCommerce Product Add-ons, by WooCommerce Print
Created by: Alex Prokaev
Modified on: Fri, 27 Nov, 2020 at 10:16 AM
Did you find it helpful? Yes No
Send feedbackSorry we couldn't be helpful. Help us improve this article with your feedback.