• Resolved jpstwisted

    (@jpstwisted)


    Hi,

    Your function add_stock_status_in_order_confirmation_update() contains an error. If you order a product variation, the stock message shown is for the variable product parent – WC_Product – not for the variation itself – WC_Product_Variation. I’ve resolved this as follows:

    	public function add_stock_status_in_order_confirmation_update( $item_id , $item , $order  ) {	
    		$variation_id = $item->get_variation_id();
    		$product_id 			= 	($variation_id == 0) ? $item->get_product_id() : $variation_id;
    		$product 				= 	($variation_id == 0) ? new WC_Product( $product_id ) : new WC_Product_Variation( $product_id );

    This will retrieve the correct availability status from the variation and save it into the postmeta.

    If you could update the official plugin, that would be great. Thanks!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Error in function logic’ is closed to new replies.