I have to use the below code to bring the restock function.
Any chance your side could fix it ASAP? The below code only can be used temporarily. Because it still restocks even when the restock checkbox is not checked.
Thanks
FYI
https://stackoverflow.com/questions/48910150/auto-restock-products-on-specific-order-status-changes-in-woocommerce
if ( ! class_exists( 'WC_Auto_Stock_Restore' ) ) {
class WC_Auto_Stock_Restore {
function __construct() {
add_action( 'woocommerce_order_status_processing_to_cancelled', array( $this, 'restore_order_stock' ), 10, 2 );
add_action( 'woocommerce_order_status_completed_to_cancelled', array( $this, 'restore_order_stock' ), 10, 2 );
add_action( 'woocommerce_order_status_on-hold_to_cancelled', array( $this, 'restore_order_stock' ), 10, 2 );
add_action( 'woocommerce_order_status_processing_to_refunded', array( $this, 'restore_order_stock' ), 10, 2 );
add_action( 'woocommerce_order_status_completed_to_refunded', array( $this, 'restore_order_stock' ), 10, 2 );
add_action( 'woocommerce_order_status_on-hold_to_refunded', array( $this, 'restore_order_stock' ), 10, 2 );
}
public function restore_order_stock( $order_id, $order ) {
$items = $order->get_items();
if ( ! get_option('woocommerce_manage_stock') == 'yes' && ! count( $items ) > 0 )
return; // We exit
foreach ( $order->get_items() as $item ) {
$product_id = $item->get_product_id();
if ( $product_id > 0 ) {
$product = $item->get_product();
if ( $product && $product->exists() && $product->managing_stock() ) {
// Get the product initial stock quantity (before update)
$initial_stock = $product->get_stock_quantity();
$item_qty = apply_filters( 'woocommerce_order_item_quantity', $item->get_quantity(), $this, $item );
// Update the product stock quantity
// Replace DEPRECATED methods: increase_stock() & discrease_stock()
wc_update_product_stock( $product, $item_qty, 'increase' );
// Get the product updated stock quantity
$updated_stock = $initial_stock + $item_qty;
do_action( 'woocommerce_auto_stock_restored', $product, $item );
// A unique Order note: Store each order note in an array…
$order_note[] = sprintf( __( 'Product ID #%s stock incremented from %s to %s.', 'woocommerce' ), $product_id, $initial_stock, $updated_stock);
// DEPRECATED & NO LONGER NEEDED - can be removed
//$order->send_stock_notifications( $product, $updated_stock, $item_qty );
}
}
}
// Adding a unique composite order note (for multiple items)
$order_notes = count($order_note) > 1 ? implode(' | ', $order_note) : $order_note[0];
$order->add_order_note( $order_notes );
}
}
$GLOBALS['wc_auto_stock_restore'] = new WC_Auto_Stock_Restore();
}
]]>There is a shirt with 3 variations (size S,M,L) that share 1 item in stock. A customer buys that single item and the product becomes Out of Stock. Good!
The customer gets the ordered item via post, the shop owner changes order status to Completed.
The customer decides to return the product and upon arrivel the order status is changed to Cancelled which logically increases the stock back to 1 item. BUT THE VARIATIONS STILL SHOW OUT OF STOCK – thus product is out of stock for the store. That status is NOT changed automatically!?
Is that the correct behaviour of Woo or is there something wrong? How can it be that there is one item in stock updated from 0, but the variations are not updated to In stock. If manually change the available stock to 2, for example, In stock is back to normal and product becomes available.
Is this ok, or it seems weird? To me it seems strange to update one thing and not update the status to In stock which is the second thing!?
Any help?
]]>We tried restocking plugin – we solved it only for simple products, but variable products are still not restocking
System check:
### WordPress Environment ###
Home URL: https://nonpareil.lv
Site URL: https://nonpareil.lv
WC Version: 3.4.2
Log Directory Writable: ✔
WP Version: 4.9.6
WP Multisite: –
WP Memory Limit: 256 MB
WP Debug Mode: –
WP Cron: ✔
Language: en_US
External object cache: –
### Server Environment ###
Server Info: Apache
PHP Version: 7.0.30 - We recommend using PHP version 7.2 or above for greater performance and security. How to update your PHP version
PHP Post Max Size: 50 MB
PHP Time Limit: 300
PHP Max Input Vars: 1000
cURL Version: 7.54.0
OpenSSL/1.0.2k
SUHOSIN Installed: –
MySQL Version: 5.6.39-cll-lve
Max Upload Size: 40 MB
Default Timezone is UTC: ✔
fsockopen/cURL: ✔
SoapClient: ✔
DOMDocument: ✔
GZip: ✔
Multibyte String: ✔
Remote Post: ✔
Remote Get: ✔
### Database ###
WC Database Version: 3.4.2
WC Database Prefix: ge_
MaxMind GeoIP Database: ✔
Total Database Size: 4.69MB
Database Data Size: 3.51MB
Database Index Size: 1.18MB
ge_woocommerce_sessions: Data: 0.03MB + Index: 0.00MB
ge_woocommerce_api_keys: Data: 0.00MB + Index: 0.00MB
ge_woocommerce_attribute_taxonomies: Data: 0.00MB + Index: 0.00MB
ge_woocommerce_downloadable_product_permissions: Data: 0.00MB + Index: 0.00MB
ge_woocommerce_order_items: Data: 0.00MB + Index: 0.00MB
ge_woocommerce_order_itemmeta: Data: 0.02MB + Index: 0.02MB
ge_woocommerce_tax_rates: Data: 0.00MB + Index: 0.01MB
ge_woocommerce_tax_rate_locations: Data: 0.00MB + Index: 0.00MB
ge_woocommerce_shipping_zones: Data: 0.00MB + Index: 0.00MB
ge_woocommerce_shipping_zone_locations: Data: 0.00MB + Index: 0.00MB
ge_woocommerce_shipping_zone_methods: Data: 0.00MB + Index: 0.00MB
ge_woocommerce_payment_tokens: Data: 0.00MB + Index: 0.00MB
ge_woocommerce_payment_tokenmeta: Data: 0.00MB + Index: 0.00MB
ge_woocommerce_log: Data: 0.00MB + Index: 0.00MB
ge_blc_filters: Data: 0.00MB + Index: 0.00MB
ge_blc_instances: Data: 0.00MB + Index: 0.00MB
ge_blc_links: Data: 0.00MB + Index: 0.01MB
ge_blc_synch: Data: 0.00MB + Index: 0.00MB
ge_commentmeta: Data: 0.00MB + Index: 0.01MB
ge_comments: Data: 0.01MB + Index: 0.01MB
ge_links: Data: 0.00MB + Index: 0.00MB
ge_lockdowns: Data: 0.00MB + Index: 0.00MB
ge_login_fails: Data: 0.00MB + Index: 0.00MB
ge_options: Data: 1.87MB + Index: 0.07MB
ge_postmeta: Data: 1.17MB + Index: 0.84MB
ge_posts: Data: 0.20MB + Index: 0.10MB
ge_revslider_css: Data: 0.09MB + Index: 0.00MB
ge_revslider_layer_animations: Data: 0.00MB + Index: 0.00MB
ge_revslider_navigations: Data: 0.00MB + Index: 0.00MB
ge_revslider_sliders: Data: 0.01MB + Index: 0.00MB
ge_revslider_slides: Data: 0.08MB + Index: 0.00MB
ge_revslider_static_slides: Data: 0.00MB + Index: 0.00MB
ge_taxonomymeta: Data: 0.00MB + Index: 0.01MB
ge_termmeta: Data: 0.00MB + Index: 0.01MB
ge_terms: Data: 0.00MB + Index: 0.01MB
ge_term_relationships: Data: 0.01MB + Index: 0.03MB
ge_term_taxonomy: Data: 0.00MB + Index: 0.01MB
ge_usermeta: Data: 0.02MB + Index: 0.02MB
ge_users: Data: 0.00MB + Index: 0.01MB
ge_wc_download_log: Data: 0.00MB + Index: 0.00MB
ge_wc_webhooks: Data: 0.00MB + Index: 0.00MB
ge_yith_wcwl: Data: 0.00MB + Index: 0.00MB
ge_yith_wcwl_lists: Data: 0.00MB + Index: 0.01MB
ge_yoast_seo_links: Data: 0.00MB + Index: 0.00MB
ge_yoast_seo_meta: Data: 0.00MB + Index: 0.00MB
### Post Type Counts ###
amn_exact-metrics: 1
attachment: 110
nav_menu_item: 16
option-tree: 2
page: 15
post: 2
product: 69
product_variation: 429
revision: 17
shop_order: 7
staticblocks: 2
wpcf7_contact_form: 2
### Security ###
Secure connection (HTTPS): ✔
Hide errors from visitors: ✔
### Active Plugins (19) ###
Broken Link Checker: by Janis Elsts
Vladimir Prelovac – 1.11.5
Contact Form 7: by Takayuki Miyoshi – 5.0.2
Google Analytics Dashboard for WP (GADWP): by ExactMetrics – 5.3.5
Head, Footer and Post Injections: by Stefano Lissa – 3.1.1
Imsanity: by Shane Bishop – 2.3.10
Instagram Feed: by Smash Balloon – 1.8.3
WPBakery Page Builder: by Michael M - WPBakery.com – 5.4.5
Login LockDown: by Michael VanDeMar – v1.7.1
My Custom Functions: by Space X-Chimp – 4.19
PW WooCommerce Bulk Edit: by Pimwick
LLC – 2.47
Regenerate Thumbnails: by Alex Mills (Viper007Bond) – 3.0.2
Slider Revolution: by ThemePunch – 5.4.6.3.1
Simple Custom CSS: by John Regan
Danny Van Kooten – 4.0.1
WooCommerce Variation Swatches: by ThemeAlien – 1.0.3 – Not tested with the active version of WooCommerce
WooCommerce Payment Gateway - Paysera: by Paysera – 2.4.8 – Not tested with the active version of WooCommerce
WooCommerce Auto Restore Stock: by Gerhard Potgieter – 1.0.1 – Not tested with the active version of WooCommerce
WooCommerce: by Automattic – 3.4.2
Yoast SEO: by Team Yoast – 7.6.1
YITH WooCommerce Wishlist: by YITHEMES – 2.2.2
### Settings ###
API Enabled: ✔
Force SSL: –
Currency: EUR (€)
Currency Position: left
Thousand Separator: ,
Decimal Separator: .
Number of Decimals: 2
Taxonomies: Product Types: external (external)
grouped (grouped)
simple (simple)
variable (variable)
Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
exclude-from-search (exclude-from-search)
featured (featured)
outofstock (outofstock)
rated-1 (rated-1)
rated-2 (rated-2)
rated-3 (rated-3)
rated-4 (rated-4)
rated-5 (rated-5)
### WC Pages ###
Shop base: #1161 - /shop/
Cart: #810 - /cart/
Checkout: #811 - /checkout/
My account: #812 - /my-account/
Terms and conditions: #1109 - /terms-conditions/
### Theme ###
Name: LEGENDA - 8theme WordPress theme
Version: 3.6
Author URL: https://themeforest.net/user/8theme
Child Theme: ❌ – If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme. See: How to create a child theme
WooCommerce Support: ✔
### Templates ###
Overrides: legenda/woocommerce/archive-product.php version 3.3.0 is out of date. The core version is 3.4.0
legenda/woocommerce/cart/cart-empty.php
legenda/woocommerce/cart/cart-shipping.php
legenda/woocommerce/cart/cart.php version 3.3.0 is out of date. The core version is 3.4.0
legenda/woocommerce/cart/cross-sells.php
legenda/woocommerce/cart/mini-cart.php
legenda/woocommerce/checkout/form-billing.php
legenda/woocommerce/checkout/form-checkout.php
legenda/woocommerce/checkout/form-coupon.php version 3.3.0 is out of date. The core version is 3.4.0
legenda/woocommerce/checkout/form-login.php version 2.0.0 is out of date. The core version is 3.4.0
legenda/woocommerce/checkout/form-shipping.php
legenda/woocommerce/checkout/review-order.php
legenda/woocommerce/content-product.php version 3.0.0 is out of date. The core version is 3.4.0
legenda/woocommerce/content-product_cat.php
legenda/woocommerce/content-single-product.php version 3.0.0 is out of date. The core version is 3.4.0
legenda/woocommerce/content-widget-product.php
legenda/woocommerce/global/form-login.php
legenda/woocommerce/global/quantity-input.php version 3.3.0 is out of date. The core version is 3.4.0
legenda/woocommerce/loop/add-to-cart.php
legenda/woocommerce/loop/loop-end.php
legenda/woocommerce/loop/loop-start.php
legenda/woocommerce/loop/no-products-found.php
legenda/woocommerce/loop/pagination.php
legenda/woocommerce/loop/rating.php
legenda/woocommerce/myaccount/form-login.php version 3.3.0 is out of date. The core version is 3.4.0
legenda/woocommerce/myaccount/my-downloads.php
legenda/woocommerce/myaccount/navigation.php
legenda/woocommerce/single-product/add-to-cart/external.php version 2.1.0 is out of date. The core version is 3.4.0
legenda/woocommerce/single-product/add-to-cart/simple.php version 3.0.0 is out of date. The core version is 3.4.0
legenda/woocommerce/single-product/meta.php
legenda/woocommerce/single-product/product-image.php version 3.1.0 is out of date. The core version is 3.3.2
legenda/woocommerce/single-product/product-thumbnails.php version 3.1.0 is out of date. The core version is 3.3.2
legenda/woocommerce/single-product/related.php
legenda/woocommerce/single-product/short-description.php
legenda/woocommerce/single-product/tabs/tabs.php
legenda/woocommerce/single-product/title.php
legenda/woocommerce/single-product/up-sells.php
legenda/woocommerce/single-product-reviews.php
legenda/woocommerce/single-product.php
Outdated Templates: ❌
Learn how to update
]]>Automatically restocking is not working, like from “Pending” to “Cancel” because of Payment Timeout, but that is just fine like that! As soon as you select an order and update the status to “Cancel” the stock will be reset correctly. This Plugin is a huge timesaver for my workflow.
]]>If an order is cancelled and no funds have been processed does that mean the tickets they had have been removed from my inventory and I need to restock them? See screenshot : https://drive.google.com/open?id=0B8LwyO5Xo6kgZVItQXBxWDNfaFU
I’m just unsure if the two tickets listed in the cancelled order have been removed from my inventory. Or if it doesn’t meant anything because to transaction never finalised.
If it has been removed from my inventory I assume I can just refund them $0 and tick the restock items box to return them to my inventory. I just don’t want to return them to the inventory if they haven’t actually be removed from the inventory meaning I’ll end of up putting more tickets in my inventory than I actually have for sale.
I hope that makes sense!
Also, I can’t seem to find a tally of my inventory. For example, if I started with 80 tickets and sold 50. I can’t find an area that shows me the original quantity I put in, only what I have remaining. So I can’t tell if the cancelled tickets have been removed from my original amount or not. I don’t want to have to go through and count all the ticket sales as I have 5 variations of tickets all with their own stock levels!
Any advise would be greatly appreciated
https://www.ads-software.com/plugins/woocommerce/
]]>