WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
order_item_meta (4 posts)

  1. jimlongo
    Member
    Posted 1 year ago #

    On my checkout page I'm trying to access data from the wp_woocommerce_order_itemmeta table.

    I've read the woocommerce_order_item_meta function and the WC_Order_Item_Meta class, but nothing I've tried will return anything on the checkout page.

    Does anyone know how i can access this information?

    Thanks for any help.

    http://wordpress.org/extend/plugins/woocommerce/

  2. jimlongo
    Member
    Posted 1 year ago #

    I guess you just query the database

    $var = $wpdb->get_var( "
    		SELECT wm.meta_value
    		FROM wp_woocommerce_order_itemmeta wm JOIN
    		wp_woocommerce_order_items wo
    		ON wm.order_item_id = wo.order_item_id
    		WHERE wo.order_item_name = 'MY ITEM'
    		AND wm.meta_key= 'MY KEY'
    		AND wo.order_id = $order->id
    					");

    This will return the meta_value from the table for this item in this order.

  3. Paulo Pinto
    Member
    Posted 5 months ago #

    Hi,
    I'm having the same trouble retrieving values from that table.
    Did you have any luck resolving the issue?
    Thanks in advance.
    Paulo

  4. brettlefty
    Member
    Posted 3 months ago #

    The order item meta is shown on the Edit Order page, so it's definitely possible to retrieve these items.

    Check out these files:
    class-wc-meta-box-order-items.php (lines 23-26, 56-65)
    ...and that file includes this one:
    html-order-item.php (lines 42-67)

    There's probably also some code to display these fields in the order email file:
    class-wc-emails.php (line 283 function order_meta)

    Basically you have to get the order, then get each product in the order, and then pull the meta values for that line item.

    If I knew more about how exactly you want to use this data, I could probably give you some custom code to put it where you want.

Topic Closed

This topic has been closed to new replies.