WooCommerce Subscriptions hook: Get Order Items

WooCommerce 3.0 broke my app and I cannot figure out how to fix it now.

I have an action for when a subscription is added/changed running here:

add_action( 'woocommerce_subscription_status_changed', 'update_subscription', 10, 3 ); 

Inside the function I was getting the order details and finding the line item for a variable subscription to update my custom DB with the option as well as getting custom order meta that I added via woocommerce_form_field:

$order = new WC_Order( $id );
$items = $order->get_items();

$subscription_type = '';
$custom_meta = get_post_meta( $order->id, 'custom_order_meta', true );

$user_id = $order->get_user_id();

foreach ($items as $item) {

    if( "Subscription" === $item['name'] ) {
        $subscription_type = $item['brand'];
    }
}

This no longer works and everything appears protected? How can I update this to work with 3.0?

Read more here: WooCommerce Subscriptions hook: Get Order Items

Leave a Reply

Your email address will not be published. Required fields are marked *