Variable Products sometimes “out of stock” after being ordered
-
Sometimes after a variation of a variable product is purchased, the product shows the following message on the frontend and can not be ordered anymore:
This product is currently out of stock and unavailable.
Stock Management is enabled in Woocommerce Settings, and every single product variant contains the following necessary information:
- Enabled checked
- Manage Stock? checked
- a Regular price set
- Stock quantity is more than 0 (like 100 or sth)
So nowhere is a hint that the product might be out of stock. The Stock column on the All Products listing is also green and shows the correct values.
I searched inside the database but i could not find a single difference compared to variable products that display correctly. Main focus was on the following tables: wp_posts, wp_postmeta, wp_wc_product_meta_lookup, wp_wc_product_attributes_lookup
The problem seems to be that woocommerce can not get any information on the product variations for the affected products. In the .variations_form element, the data-attribute data-product_variations is equal to an empty array (data-product_variations=”[]”).
When going into the responsible code file (/plugins/woocommerce/includes/class-wc-product-variable.php) and looking at the function get_available_variations, I can log that the get_children() function returns an empty array and that the has_child() function returns false (while is_type(‘variable’) ist still true, as it should be).
// around line 300 /** * Get an array of available variations for the current product. * * @param string $return Optional. The format to return the results in. Can be 'array' to return an array of variation data or 'objects' for the product objects. Default 'array'. * * @return array[]|WC_Product_Variation[] */ public function get_available_variations( $return = 'array' ) { if( $this->is_type('variable') ) { $children_ids = $this->get_children(); if(empty($children_ids)) { if(!$this->has_child()) { echo 'The product has no children'; // THIS GETS LOGGED } else { echo 'The product has children but they are not visible or not synced properly'; } } else { echo 'Children IDs: ' . implode(', ', $children_ids); } } else { echo 'The product is not a variable product'; }
The error can not be reproduced consistently but still occurs on quite a regular basis. That’s the reason why it’s really hard to debug and I can still not completely rule out a plugin/theme conflict. But when the error triggers and the product shows the “out of stock” message, I can switch to storefront theme and disable all plugins except woocommerce and the product still shows as out of stock.
So my question for now is:
There needs to be some sort of traceability when having every plugin disabled and using the default theme that allows me to see, what differentiates the out of stock product from a product that displays correctly. Is there a caching layer I need to check? or did I miss a database table that would contain the necessary information.Thank’s in advance for helping out. After spending around 15 hours researching and debugging this issue, I’m quite frustrated as you can imagine.
System report:
` WordPress Environment WordPress address (URL): https://testing.haltbarmacherei.ch<br>Site address (URL): https://testing.haltbarmacherei.ch<br>WC Version: 8.0.1<br>REST API Version: ✔ 8.0.1<br>WC Blocks Version: ✔ 10.6.5<br>Action Scheduler Version: ✔ 3.6.1<br>Log Directory Writable: ✔<br>WP Version: 6.3<br>WP Multisite: –<br>WP Memory Limit: 256 MB<br>WP Debug Mode: –<br>WP Cron: ✔<br>Language: de_DE<br>External object cache: – Server Environment Server Info: Apache<br>PHP Version: 8.2.8<br>PHP Post Max Size: 256 MB<br>PHP Time Limit: 60<br>PHP Max Input Vars: 200000<br>cURL Version: 8.1.2<br>NSS/3.79 SUHOSIN Installed: –<br>MySQL Version: 10.6.14-MariaDB<br>Max Upload Size: 256 MB<br>Default Timezone is UTC: ✔<br>fsockopen/cURL: ✔<br>SoapClient: ✔<br>DOMDocument: ✔<br>GZip: ✔<br>Multibyte String: ✔<br>Remote Post: ✔<br>Remote Get: ✔ Database WC Database Version: 8.0.1<br>WC Database Prefix: 1qVcX6wgl_<br>Total Database Size: 35.03MB<br>Database Data Size: 25.55MB<br>Database Index Size: 9.48MB<br>1qVcX6wgl_woocommerce_sessions: Data: 0.06MB + Index: 0.02MB + Engine InnoDB<br>1qVcX6wgl_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>1qVcX6wgl_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>1qVcX6wgl_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB<br>1qVcX6wgl_woocommerce_order_items: Data: 0.17MB + Index: 0.06MB + Engine InnoDB<br>1qVcX6wgl_woocommerce_order_itemmeta: Data: 1.52MB + Index: 3.03MB + Engine InnoDB<br>1qVcX6wgl_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB<br>1qVcX6wgl_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>1qVcX6wgl_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>1qVcX6wgl_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>1qVcX6wgl_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>1qVcX6wgl_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>1qVcX6wgl_actionscheduler_actions: Data: 0.19MB + Index: 0.19MB + Engine InnoDB<br>1qVcX6wgl_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>1qVcX6wgl_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>1qVcX6wgl_actionscheduler_logs: Data: 0.16MB + Index: 0.13MB + Engine InnoDB<br>1qVcX6wgl_cmeb_email_list: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_cmeb_free_domains: Data: 0.13MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_cmeb_userlist: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>1qVcX6wgl_comments: Data: 0.31MB + Index: 0.09MB + Engine InnoDB<br>1qVcX6wgl_db7_forms: Data: 0.06MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_gglcptch_allowlist: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>1qVcX6wgl_gla_attribute_mapping_rules: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_gla_budget_recommendations: Data: 0.22MB + Index: 0.14MB + Engine InnoDB<br>1qVcX6wgl_gla_merchant_issues: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_gla_shipping_rates: Data: 0.02MB + Index: 0.05MB + Engine InnoDB<br>1qVcX6wgl_gla_shipping_times: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>1qVcX6wgl_imagify_files: Data: 0.06MB + Index: 0.08MB + Engine InnoDB<br>1qVcX6wgl_imagify_folders: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>1qVcX6wgl_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>1qVcX6wgl_options: Data: 2.20MB + Index: 0.20MB + Engine InnoDB<br>1qVcX6wgl_postmeta: Data: 3.42MB + Index: 2.98MB + Engine InnoDB<br>1qVcX6wgl_posts: Data: 14.52MB + Index: 0.23MB + Engine InnoDB<br>1qVcX6wgl_redirection_404: Data: 0.16MB + Index: 0.08MB + Engine InnoDB<br>1qVcX6wgl_redirection_groups: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>1qVcX6wgl_redirection_items: Data: 0.02MB + Index: 0.09MB + Engine InnoDB<br>1qVcX6wgl_redirection_logs: Data: 0.02MB + Index: 0.05MB + Engine InnoDB<br>1qVcX6wgl_rm_fields: Data: 0.13MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_rm_forms: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_rm_front_users: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_rm_login: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_rm_login_log: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_rm_notes: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_rm_paypal_fields: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_rm_paypal_logs: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_rm_rows: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_rm_rules: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_rm_sent_mails: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_rm_sessions: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_rm_stats: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_rm_submissions: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_rm_submission_fields: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_rm_tabs: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_rm_tasks: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_rm_task_exe_log: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>1qVcX6wgl_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>1qVcX6wgl_term_relationships: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>1qVcX6wgl_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>1qVcX6wgl_usermeta: Data: 0.31MB + Index: 0.31MB + Engine InnoDB<br>1qVcX6wgl_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB<br>1qVcX6wgl_wcpdf_invoice_number: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_wcpdf_packing_slip_number: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_wc_admin_notes: Data: 0.09MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_wc_admin_note_actions: Data: 0.08MB + Index: 0.02MB + Engine InnoDB<br>1qVcX6wgl_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>1qVcX6wgl_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>1qVcX6wgl_wc_orders: Data: 0.02MB + Index: 0.11MB + Engine InnoDB<br>1qVcX6wgl_wc_orders_meta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>1qVcX6wgl_wc_order_addresses: Data: 0.02MB + Index: 0.06MB + Engine InnoDB<br>1qVcX6wgl_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>1qVcX6wgl_wc_order_operational_data: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>1qVcX6wgl_wc_order_product_lookup: Data: 0.19MB + Index: 0.27MB + Engine InnoDB<br>1qVcX6wgl_wc_order_stats: Data: 0.06MB + Index: 0.05MB + Engine InnoDB<br>1qVcX6wgl_wc_order_tax_lookup: Data: 0.05MB + Index: 0.03MB + Engine InnoDB<br>1qVcX6wgl_wc_product_attributes_lookup: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>1qVcX6wgl_wc_product_download_directories: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>1qVcX6wgl_wc_product_meta_lookup: Data: 0.02MB + Index: 0.09MB + Engine InnoDB<br>1qVcX6wgl_wc_rate_limits: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>1qVcX6wgl_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>1qVcX6wgl_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>1qVcX6wgl_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>1qVcX6wgl_yoast_indexable: Data: 0.08MB + Index: 0.09MB + Engine InnoDB<br>1qVcX6wgl_yoast_indexable_hierarchy: Data: 0.02MB + Index: 0.05MB + Engine InnoDB<br>1qVcX6wgl_yoast_migrations: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>1qVcX6wgl_yoast_primary_term: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>1qVcX6wgl_yoast_seo_links: Data: 0.02MB + Index: 0.03MB + Engine InnoDB Post Type Counts attachment: 79<br>b2bking_custom_role: 2<br>b2bking_group: 1<br>custom_css: 2<br>et_body_layout: 7<br>et_footer_layout: 1<br>et_header_layout: 1<br>et_pb_layout: 2<br>et_template: 16<br>et_theme_builder: 1<br>filter-field: 2<br>filter-set: 1<br>is_search_form: 1<br>nav_menu_item: 6<br>oembed_cache: 2<br>page: 13<br>post: 2<br>product: 38<br>product_variation: 44<br>revision: 456<br>shop_coupon: 3<br>shop_order: 275<br>wp_global_styles: 1<br>wpcf7_contact_form: 2<br>yith-wcbm-badge: 3 Security Secure connection (HTTPS): ✔<br>Hide errors from visitors: ✔ Active Plugins (25) Query Monitor: by John Blackbourn – 3.13.1<br>Product Stock Manager: by Addify – 1.0.5<br>Ban Hammer: by Mika Epstein – 3.1.2<br>Blackhole for Bad Bots: by Jeff Starr – 3.6<br>Cancel order request for WooCommerce: by PI Websolution – 1.3.3.13<br>Conditional Fields for Contact Form 7: by Jules Colle – 2.3.10<br>CF7 to Webhook: by Mário Valney – 2.3.0<br>Contact Form 7: by Takayuki Miyoshi – 5.8<br>Contact Form CFDB7: by Arshid – 1.2.6.7<br>Exclude Image Thumbnails From UpdraftPlus Backups: by Dream-Encode – 1.0.3<br>Filter Everything — WooCoomerce Product & WordPress Filter: by Andrii Stepasiuk – 1.7.15<br>reCaptcha by BestWebSoft: by BestWebSoft – 1.72<br>Google Listings and Ads: by WooCommerce – 2.5.2<br>Imagify: by Imagify – Optimize Images & Convert WebP – 2.1.1<br>Kadence WooCommerce Email Designer: by Kadence WP – 1.5.11<br>Loco Translate: by Tim Whitlock – 2.6.4<br>Redirection: by John Godley – 5.3.10<br>UpdraftPlus - Backup/Restore: by UpdraftPlus.Com<br>DavidAnderson – 1.23.9 WP Menu Cart: by WP Overnight – 2.14.1<br>PDF Invoices & Packing Slips for WooCommerce: by WP Overnight – 3.5.6<br>WooCommerce: by Automattic – 8.0.1<br>Yoast SEO: by Team Yoast – 20.13<br>Custom Product Tabs for WooCommerce: by YIKES<br>Inc. – 1.8.4 YITH WooCommerce Badge Management: by YITH – 2.19.0<br>zahls.ch Credit Cards, PostFinance and TWINT for WooCommerce: by siebenberge gmbh – 1.2.4 Inactive Plugins (4) All-in-One WP Migration: by ServMask – 7.77<br>All-in-One WP Migration Unlimited Extension: by ServMask – 2.52<br>WooCommerce Wholesale Prices: by Rymera Web Co – 2.1.8<br>WooCommerce Wholesale Prices Premium: by Rymera Web Co – 1.30.3 Dropin Plugins (1) db.php: Query Monitor Database Class (Drop-in) Settings API Enabled: ✔<br>Force SSL: –<br>Currency: CHF (CHF)<br>Currency Position: left_space<br>Thousand Separator: '<br>Decimal Separator: .<br>Number of Decimals: 2<br>Taxonomies: Product Types: external (external)<br>grouped (grouped)<br>simple (simple)<br>variable (variable) Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)<br>exclude-from-search (exclude-from-search)<br>featured (featured)<br>outofstock (outofstock)<br>rated-1 (rated-1)<br>rated-2 (rated-2)<br>rated-3 (rated-3)<br>rated-4 (rated-4)<br>rated-5 (rated-5) Connected to WooCommerce.com: ✔<br>Enforce Approved Product Download Directories: ✔<br>HPOS feature screen enabled: –<br>HPOS feature enabled: –<br>Order datastore: WC_Order_Data_Store_CPT<br>HPOS data sync enabled: – WC Pages Shop base: #22 - /shop/<br>Cart: #23 - /warenkorb/<br>Checkout: #24 - /kasse/<br>My account: #25 - /mein-konto/<br>Terms and conditions: #391 - /agb/ Theme Name: haltbarmacherei<br>Version: 4.17.3.1651764343<br>Author URL:<br>Child Theme: ✔<br>Parent Theme Name: Divi<br>Parent Theme Version: 4.22.0<br>Parent Theme Author URL: http://www.elegantthemes.com<br>WooCommerce Support: ✔ Templates Overrides: – Admin Enabled Features: activity-panels<br>analytics<br>product-block-editor<br>coupons<br>core-profiler<br>customer-effort-score-tracks<br>import-products-task<br>experimental-fashion-sample-products<br>shipping-smart-defaults<br>shipping-setting-tour<br>homescreen<br>marketing<br>mobile-app-banner<br>navigation<br>onboarding<br>onboarding-tasks<br>remote-inbox-notifications<br>remote-free-extensions<br>payment-gateway-suggestions<br>shipping-label-banner<br>subscriptions<br>store-alerts<br>transient-notices<br>woo-mobile-welcome<br>wc-pay-promotion<br>wc-pay-welcome-page Disabled Features: minified-js<br>new-product-management-experience<br>product-variation-management<br>settings<br>async-product-editor-category-field Daily Cron: ✔ Next scheduled: 2023-08-15 07:19:36 +02:00<br>Options: ✔<br>Notes: 148<br>Onboarding: completed Action Scheduler Complete: 496<br>Oldest: 2023-07-15 04:04:38 +0200<br>Newest: 2023-08-14 21:04:42 +0200 Failed: 5<br>Oldest: 2023-01-25 10:08:06 +0100<br>Newest: 2023-06-02 11:36:58 +0200 Pending: 2<br>Oldest: 2023-08-15 05:14:47 +0200<br>Newest: 2023-08-15 17:14:52 +0200 Status report information Generated at: 2023-08-14 21:15:44 +02:00<br>`
The page I need help with: [log in to see the link]
- You must be logged in to reply to this topic.