WooCommerce Extra Product Options (By ThemeHigh)
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 |
add_filter( 'wpo_get_item_by_product', function ( $item, $item_data, $product ) { if ( empty( $item_data['thwepo_options'] ) ) { return $item; } $item['thwepo_options'] = $item_data['thwepo_options']; $item['thwepo-original_price'] = $item_data['thwepo-original_price']; return $item; }, 10, 3 ); add_filter( 'wpo_update_cart_cart_item_meta', function ( $cart_item_meta, $item, $items ) { if ( empty( $item['thwepo_options'] ) ) { return $cart_item_meta; } $cart_item_meta['thwepo_options'] = $item['thwepo_options']; $cart_item_meta['thwepo-original_price'] = $item['thwepo-original_price']; return $cart_item_meta; }, 10, 3 ); add_filter( 'wpo_update_cart_loaded_product', function ( $loaded_product, $cart_item ) { if ( empty( $cart_item['thwepo_options'] ) ) { return $loaded_product; } $loaded_product['thwepo_options'] = $cart_item['thwepo_options']; $loaded_product['thwepo-original_price'] = $cart_item['thwepo-original_price']; $loaded_product['readonly_custom_meta_fields_html'] = wc_get_formatted_cart_item_data($cart_item); return $loaded_product; }, 10, 2 ); |