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') ) {
    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') ) {
    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" );
				}
			} );
		} );