• Resolved s93ncer

    (@s93ncer)


    Can anyone see why this code doesn’t get me an array of products and quantities
    I’ve looked at it so many time and spent hours on google with no luck
    Woocommerce is on 3.1.0 but could update if required

     $ser_order = wc_get_order( $order_id );
     
      $ser_products = $ser_order->get_items();
    	foreach($ser_products as $ser_prod){
    
    	$ser_product_variation_id = $ser_prod['variation_id'];
    
    		 if ($ser_product_variation_id) { 
        			$ser_product = new WC_Product($ser_prod['variation_id']);
    			 	$ser_skus[$ser_prod['variation_id']] = $ser_product->get_sku();
      				$ser_items[$ser_prod['variation_id']] = $ser_prod['qty'];
      			} else {
       		 		$ser_product = new WC_Product($ser_prod['product_id']);
      				$ser_skus[$ser_prod['product_id']] = $ser_product->get_sku();
      				$ser_items[$ser_prod['product_id']] = $ser_prod['qty'];
    			 }
    		}
  • The topic ‘Get products from Order’ is closed to new replies.