Title: Error in function logic
Last modified: May 19, 2021

---

# Error in function logic

 *  Resolved [jpstwisted](https://wordpress.org/support/users/jpstwisted/)
 * (@jpstwisted)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/error-in-function-logic/)
 * 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)

 *  Plugin Author [Softound Solutions](https://wordpress.org/support/users/softound/)
 * (@softound)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/error-in-function-logic/#post-14580290)
 * [@jpstwisted](https://wordpress.org/support/users/jpstwisted/)
 * Updated in latest version 1.2.6

Viewing 1 replies (of 1 total)

The topic ‘Error in function logic’ is closed to new replies.

 * ![](https://ps.w.org/woo-custom-stock-status/assets/icon-256x256.png?rev=3407025)
 * [Advanced Custom Stock Status](https://wordpress.org/plugins/woo-custom-stock-status/)
 * [Support Threads](https://wordpress.org/support/plugin/woo-custom-stock-status/)
 * [Active Topics](https://wordpress.org/support/plugin/woo-custom-stock-status/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woo-custom-stock-status/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woo-custom-stock-status/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Softound Solutions](https://wordpress.org/support/users/softound/)
 * Last activity: [4 years, 10 months ago](https://wordpress.org/support/topic/error-in-function-logic/#post-14580290)
 * Status: resolved