Skip to content
Advertisement

Get protected custom order item meta data array from WooCommerce order

I’am trying to use woocommerce_get_order_item_totals filter hook to add some extra information into the order totals (on orders and email notifications).

JavaScript

I have access to $order which contains the data I want to display but I have no idea how to get it.

Below is a var_dump (formatted) of $order variable:

JavaScript

I want to access:

JavaScript

To calculate and get the cost from ticket_price by ticket_qty.

Is this possible? Any idea on how to get this specific order item meta data?

Advertisement

Answer

To get order item custom meta data, first you need to loop through order items, to be able to get that complex custom protected meta data using WC_Data method get_meta(). Then you will be able to get and calculate your “2nd installment cost as follows:

JavaScript

Code goes in functions.php file of your active child theme (or active theme). It should works.

Related:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement