sikedelic
Forum Replies Created
-
Hello @alexmigf apologies I only saw this today.
I’m not sure if this is the best solution but what i did was let the suborder come in as a normal order and then restore the stocks. Please bear in mind that I am still learning php and no where near qualified lol. Might be a long read but see below if you wanna have a look. I hooked after (‘save_post_shop_order’) SLW is 10,3 Custom is 10,4.
//ADDED THIS CODE TO REVERSE BACK THE STOCK DEDUCTED IF A SUBORDER IS CREATED add_action('save_post_shop_order','update_stock_locations_data_wc_order_save_custom',10,4); function update_stock_locations_data_wc_order_save_custom($post_id,$post){ //GET AN INSTANCE OF WOOCOMMERCE $order OBJECT $sub_order = wc_get_order( $post_id ); $parent_order = wp_get_post_parent_id( $sub_order->get_id()); //CHECK FOR PARENT if ( ! $parent_order ) { return; } //LOOP $sub_order ONLY IF $parent_order EXISTS foreach ( $sub_order->get_items() as $sub_order_item_id => $sub_order_item ) { if ( ! $sub_order_item->is_type( 'line_item' ) ) { continue; } //WOOCOMMERCE PART $sub_order_product_id = $sub_order_item->get_product_id(); $sub_order_qty = $sub_order_item->get_quantity(); $sub_order_current_stock = get_field('_stock',$sub_order_product_id); //UPDATE $sub_order_correct_stock = $sub_order_current_stock + $sub_order_qty; update_post_meta($sub_order_product_id,'_stock',$sub_order_correct_stock); if ($sub_order_correct_stock > 0) { //UPDATE STATUS IN POSTMETA TABLE update_post_meta($sub_order_product_id,'_stock_status','instock'); } //SLW PART $sub_order_slw_data = $sub_order_item->get_meta('_slw_data'); //LOOP THROUGH ARRAY DATA foreach ($sub_order_slw_data as $sub_order_location_id => $sub_order_location ){ foreach ($sub_order_location as $key => $value){ $sub_order_quantity_subtracted = ($sub_order_location['quantity_subtracted']); $sub_order_post_meta_key = '_stock_at_'.$sub_order_location_id; $sub_order_current_stock_at_location = get_field($sub_order_post_meta_key,$sub_order_product_id); $sub_order_updated_qty = $sub_order_current_stock_at_location + $sub_order_quantity_subtracted ; //UPDATE update_post_meta ($sub_order_product_id,$sub_order_post_meta_key,$sub_order_updated_qty); } } } }If you have any suggestions or a better way i’d really appreciate it.
Hey Alex thanks for getting back to me, managed to fix this issue just a couple of hours ago ;).
Hello @rur165 ,
Thanks for getting back to meTotally forgot coupons is a pro-feature apologies.
Fortunately i’ve managed to solve the issue on my side, but I think it would be great if your dev team handled this in one of your future updates as this is quite crucial IMO. Being able to set percentage discount exceeding admin comm is a big yikes.
@rur165 I can confirm this issue has not yet been fixed in yesterdays release with 3.1.1
or maybe i’m missing something?Edit! So, if a vendor types in a new tag it will search if that tag exists if not it will create it after so vendors just have to wait abit.
This is resolved!!
- This reply was modified 5 years, 2 months ago by sikedelic.
Hello Alex, hope you are well.
Thanks for the update and I can confirm that 1.4.1 fixes this issue. Welldone! However, if you could kindly extend yourself on my now new issue.
I am running a Market Place that means I have multiple Sellers. So, if an order comes in from a customer (example Order#1) which contains products from multiple sellers lets say 2 for this case. The Main order (order #1) is broken into suborders like (SubOrder #2) & (SubOrder #3) pls see this. SLW is deducting the stock from the Main Order which is okay cause that’s how it should work but it is also deducting stocks from the suborders which is duplicating the reduction. Please note that if and order comes in only containing products from one seller then EVERYTHING IS FINE.
Any help on this would be appreciated.
Thanks once again Alex!
Forum: Plugins
In reply to: [Stock Locations for WooCommerce] Export stock@martijnschuman @alexmigf Just use the woocommerce export / import feature as it exports all the meta data. When importing it will update the existing meta data aswell.
Thanks Alex llooking forward to it
Yeah… im just tied up with another priority work atm and then i’ll look into it again. Havent had time today. Meanwhile if you get a solution lemme know. Thanks
Hey Roshini, hope you are well.
Is there a way I can hook into removing Inventory options from when the form is called by vendor?
The issue is admin (us) is managing the stock on behalf of the vendor, so if a vendor has called the form (new-product-single.php) it holds the woocommerce ‘_stock’ (example ‘_stock’=3) and so while vendor is still editing a customer places order of 1 ‘_stock’ reduces to 2 which is correct and then vendor saves the product hence bringing the ‘_stock’ back to 3 which at this point is incorrect.
What can solve the issue is if the vendor calls the form and leaves out inventory variables so when saving, the inventory variables are intact. I’m not sure if this is an oversite from your end but any help would be greatly appreciated.
Thanks!