Advanced Product Fields (Product Addons) for WooCommerce
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
add_filter('wpo_get_item_by_product', function ($product, $item_data) { if ( isset( $item_data['wapf'] ) ) { $product['wapf'] = $item_data['wapf']; } if ( isset( $item_data['wapf_key'] ) ) { $product['wapf_key'] = $item_data['wapf_key']; } if ( isset( $item_data['wapf_field_groups'] ) ) { $product['wapf_field_groups'] = $item_data['wapf_field_groups']; } if ( isset( $item_data['wapf_clone'] ) ) { $product['wapf_clone'] = $item_data['wapf_clone']; } if ( isset( $item_data['wapf_item_price'] ) ) { $product['wapf_item_price'] = $item_data['wapf_item_price']; } return $product; }, 10, 2); add_filter('wpo_update_cart_loaded_product', function ($loaded_product, $item) { if ( isset( $item['wapf'] ) ) { $loaded_product['wapf'] = $item['wapf']; $loaded_product['readonly_custom_meta_fields_html'] = wc_get_formatted_cart_item_data($item); } if ( isset( $item['wapf_key'] ) ) { $loaded_product['wapf_key'] = $item['wapf_key']; } if ( isset( $item['wapf_field_groups'] ) ) { $loaded_product['wapf_field_groups'] = $item['wapf_field_groups']; } if ( isset( $item['wapf_clone'] ) ) { $loaded_product['wapf_clone'] = $item['wapf_clone']; } if ( isset( $item['wapf_item_price'] ) ) { $loaded_product['wapf_item_price'] = $item['wapf_item_price']; } return $loaded_product; }, 10, 2); add_filter('wpo_update_cart_cart_item_meta', function ($cart_item_meta, $item) { if ( isset( $item['wapf'] ) ) { $cart_item_meta['wapf'] = $item['wapf']; } if ( isset( $item['wapf_key'] ) ) { $cart_item_meta['wapf_key'] = $item['wapf_key']; } if ( isset( $item['wapf_field_groups'] ) ) { $cart_item_meta['wapf_field_groups'] = $item['wapf_field_groups']; } if ( isset( $item['wapf_clone'] ) ) { $cart_item_meta['wapf_clone'] = $item['wapf_clone']; } if ( isset( $item['wapf_item_price'] ) ) { $cart_item_meta['wapf_item_price'] = $item['wapf_item_price']; } return $cart_item_meta; }, 10, 2); |