Show specific meta data on cart with WC_Cart
-
I want to show more details on the cart in a Woocommerce page.
The code in the current format is this one:
// Meta data echo WC()->cart->get_item_data( $cart_item );
When I print it as an array only a few of the meta data are there. I can see more on the SQL table wp_postmeta, which are not returned with the get_item_data.
So, is there any other way to retrieve specific meta data for the product without using queries?
I tried something:
global $woocommerce ,$product, $post; $other_data = get_post_meta( $cart_item["product_id"] ); echo '<pre>'; print_r($other_data); echo '</pre>';
But the array is not the one with the right data. It returns the settings from the product and not the meta data from booking that I need.
I tried also:
$wpdb->get_results("select * from $wpdb->postmeta where meta_key='_booking_start'");
This one returns all the data with the meta_key I want…However, if I do the following, the results are an empty array.
$id = get_the_ID(); $start_dates = $wpdb->get_results("select * from $wpdb->postmeta where meta_key='_booking_start' and post_id=$id");
- The topic ‘Show specific meta data on cart with WC_Cart’ is closed to new replies.