Get Woocommerce Product ID
add_action( 'woocommerce_thankyou', 'order_created_get_skus', 10 );
function order_created_get_skus($order_id){
$item_sku = array();
$order = wc_get_order( $order_id );
foreach ($order->get_items() as $item) {
// $product = wc_get_product($item->get_product_id());
// $item_sku[] = $product->get_sku();
echo "product id: " . $item->get_product_id();
}
// now do something with the sku array
}
Comments
Post a Comment