inibori
Forum Replies Created
Viewing 1 replies (of 1 total)
-
This is my code:
add_action( 'woocommerce_payment_complete', 'api_add_order'); function api_add_order($order_id){ $order = new WC_Order($order_id); $order_username = do_shortcode( '[wcj_order_items_meta order_id="' . $order_id . '" meta_key="_wcj_product_input_fields_global_1"]' ); $fp = fopen('vardump.txt', 'w'); fwrite($fp, serialize($order_username)); fclose($fp); $items = $order->get_items(); foreach ( $items as $item ) { $product_id = $item['product_id']; $product = new WC_Product($item['product_id']); if ( has_term( 'api', 'product_cat', $product_id ) ) { $sku = explode("-", $product->get_sku()); $service = $sku[0]; $username = $order_username; $quantity = $sku[1]; } } }I feel like I have tried everything but it always returns nothing, I can access everything else like the sku and first or last name… but i cant seem to get the order meta like the input fields input.
Is it possible that it gets added to the order meta after “woocommerce_payment_complete” ?
Viewing 1 replies (of 1 total)