WooCommerce TM Extra Product Options
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 |
add_filter('wpo_update_cart_cart_item_meta', function ($cart_item_meta, $item) { return array_merge($cart_item_meta, array( 'tmpost_data' => isset($item['tmpost_data']) ? $item['tmpost_data'] : null, )); }, 10, 2); add_filter('wpo_update_cart_loaded_product', function ($loaded_product, $item) { return array_merge($loaded_product, array( 'tmpost_data' => isset($item['tmpost_data']) ? $item['tmpost_data'] : null, 'readonly_price' => isset($item['tm_epo_product_price_with_options']) ? $item['tm_epo_product_price_with_options'] : null, 'readonly_custom_meta_fields_html' => isset($item['tmcartepo']) ? wc_get_formatted_cart_item_data($item) : '', )); }, 10, 2); add_filter('wpo_get_item_by_product', function ($product, $cart_item_data) { return array_merge($product, array( 'tmpost_data' => isset($cart_item_data['tmpost_data']) ? $cart_item_data['tmpost_data'] : null, )); }, 10, 2); add_filter('wpo_cart_item_is_price_readonly', function ($is_readonly, $cart_item_data) { return isset($cart_item_data['tmpost_data']) && $cart_item_data['tmpost_data'] ? true : $is_readonly; }, 10, 2); add_filter('woocommerce_add_cart_item_data', function ($cart_item_data, $product_id) { if ( isset( $cart_item_data['tmpost_data'] ) && function_exists('TM_EPO') && !isset($_POST['add-to-cart']) ) { return TM_EPO()->tm_add_cart_item_data( $cart_item_data, $product_id, $cart_item_data['tmpost_data'] ); } if ( isset( $cart_item_data['tmpost_data'] ) && function_exists('THEMECOMPLETE_EPO_Cart') && !isset($_POST['add-to-cart']) ) { return THEMECOMPLETE_EPO_Cart()->tm_add_cart_item_data( $cart_item_data, $product_id, $cart_item_data['tmpost_data'] ); } return $cart_item_data; }, 70, 2); //correctly show item options add_action( "wpo_init_frontend_page", function () { add_action( 'wp_enqueue_scripts', function () { if ( defined( "THEMECOMPLETE_EPO_PLUGIN_URL" ) && defined( "THEMECOMPLETE_EPO_VERSION" ) ) { $tm_src = THEMECOMPLETE_EPO_PLUGIN_URL . '/assets/css/tm-epo.min.css'; add_filter( 'wpo_frontend_disable_load_src', function ( $disable, $src ) use ( $tm_src ) { return $disable ? $tm_src !== substr( $src, 0, strlen( $tm_src ) ) : false; }, 10, 2 ); wp_enqueue_style( 'themecomplete-epo', $tm_src, false, THEMECOMPLETE_EPO_VERSION, "all" ); } } ); } ); |