woocommerce / woocommerce

A customizable, open-source ecommerce platform built on WordPress. Build any commerce solution you can imagine.
https://woocommerce.com
9.41k stars 10.76k forks source link

Variable product display as 'out of stock' when there is stock. #23645

Closed odirlon closed 4 years ago

odirlon commented 5 years ago

Describe the bug I have long been noticing that some products are shown as stock out of stock even though it is perfectly configured. Sometimes it is enough to update the product (without changing anything in it, just opening the product and clicking on update) it already leaves the message "out of stock", other times it is necessary to add an additional item in some variation, to update the product and then remove the item added to the out-of-stock message exit.

I ended up thinking that it could be a bug of my theme, however the message is in the admin panel as well as can be checked in the prints.

But on the product screen the purchase is carried out quietly, this message does not stop the purchase, but leaves the thing a little confused.

Screenshots (Admin - Listagem de produtos): image

(Admin - abas do produto): image image

(Front - Listagem de produtos): image

Expected behavior I believe that the normal behavior was to know that the product has stock, and not to display that message.

Isolating the problem (mark completed items with an [x]):

WordPress Environment

``` Ambiente do WordPress Endereço do WordPress (URL): https://cshoes.com.br Endereço do site (URL): https://cshoes.com.br Versão do WooCommerce: 3.6.2 Diretório gravável de registros: /home/cshoes/public_html/wp-content/uploads/wc-logs/ Versão do WordPress: 5.2 WordPress multisite: – Limite de memória do WordPress: 512 MB Modo de depuração do WordPress: – WordPress cron: Idioma: pt_BR Cache de objeto externo: – Ambiente do servidor Informações do servidor: Apache Versão do PHP: 7.2.7 Tamanho máximo para post no PHP: 512 MB Limite de tempo do PHP: 600 Máximo de entrada de variáveis (max input vars) do PHP: 4000 Versão do cURL: 7.59.0, OpenSSL/1.0.2o SUHOSIN instalado: – Versão do MySQL: 5.5.5-10.2.16-MariaDB Tamanho máximo de upload: 512 MB O fuso horário padrão é UTC: fsockopen/cURL: SoapClient: DOMDocument: GZip: Multibyte string: Requisição remota do tipo POST: Requisição remota do tipo GET: Banco de dados Versão do banco de dados do WooCommerce: 3.4.5 Prefixo do banco de dados wp_ Banco de dados GeoIP da MaxMind: /home/cshoes/public_html/wp-content/uploads/GeoLite2-Country.mmdb Tamanho total do banco de dados 15.61MB Tamanho dos dados do banco de dados 11.44MB Tamanho do índice do banco de dado 4.17MB wp_woocommerce_sessions Dados: 0.00MB + Índices: 0.00MB wp_woocommerce_api_keys Dados: 0.00MB + Índices: 0.01MB wp_woocommerce_attribute_taxonomies Dados: 0.00MB + Índices: 0.00MB wp_woocommerce_downloadable_product_permissions Dados: 0.00MB + Índices: 0.00MB wp_woocommerce_order_items Dados: 0.03MB + Índices: 0.03MB wp_woocommerce_order_itemmeta Dados: 0.28MB + Índices: 0.18MB wp_woocommerce_tax_rates Dados: 0.00MB + Índices: 0.00MB wp_woocommerce_tax_rate_locations Dados: 0.00MB + Índices: 0.00MB wp_woocommerce_shipping_zones Dados: 0.00MB + Índices: 0.00MB wp_woocommerce_shipping_zone_locations Dados: 0.00MB + Índices: 0.00MB wp_woocommerce_shipping_zone_methods Dados: 0.00MB + Índices: 0.00MB wp_woocommerce_payment_tokens Dados: 0.00MB + Índices: 0.00MB wp_woocommerce_payment_tokenmeta Dados: 0.00MB + Índices: 0.00MB wp_woocommerce_log Dados: 0.00MB + Índices: 0.00MB wp_atum_order_itemmeta Dados: 0.00MB + Índices: 0.00MB wp_atum_order_items Dados: 0.00MB + Índices: 0.00MB wp_atum_product_data Dados: 0.01MB + Índices: 0.02MB wp_categorymeta Dados: 0.00MB + Índices: 0.00MB wp_commentmeta Dados: 0.00MB + Índices: 0.01MB wp_comments Dados: 0.28MB + Índices: 0.14MB wp_failed_jobs Dados: 0.00MB + Índices: 0.00MB wp_links Dados: 0.00MB + Índices: 0.00MB wp_mailchimp_carts Dados: 0.00MB + Índices: 0.00MB wp_member_catmeta Dados: 0.00MB + Índices: 0.00MB wp_options Dados: 3.14MB + Índices: 0.30MB wp_portfolio_catmeta Dados: 0.00MB + Índices: 0.00MB wp_postmeta Dados: 4.14MB + Índices: 1.50MB wp_posts Dados: 1.14MB + Índices: 0.18MB wp_product_catmeta Dados: 0.00MB + Índices: 0.00MB wp_queue Dados: 0.00MB + Índices: 0.00MB wp_stream Dados: 0.36MB + Índices: 0.26MB wp_stream_meta Dados: 0.95MB + Índices: 0.88MB wp_termmeta Dados: 0.00MB + Índices: 0.01MB wp_terms Dados: 0.00MB + Índices: 0.02MB wp_term_relationships Dados: 0.03MB + Índices: 0.06MB wp_term_taxonomy Dados: 0.01MB + Índices: 0.01MB wp_usermeta Dados: 1.01MB + Índices: 0.47MB wp_users Dados: 0.03MB + Índices: 0.04MB wp_wc_download_log Dados: 0.00MB + Índices: 0.00MB wp_wc_product_meta_lookup Dados: 0.03MB + Índices: 0.04MB wp_wc_webhooks Dados: 0.00MB + Índices: 0.00MB wp_woof_query_cache Dados: 0.00MB + Índices: 0.00MB wp_yith_wcwl Dados: 0.00MB + Índices: 0.00MB wp_yith_wcwl_lists Dados: 0.00MB + Índices: 0.01MB Contas de tipo de post attachment 376 banners-grid 1 block 18 custom_css 1 customize_changeset 1 cwginstocknotifier 4 faq 10 fp_waitlist 20 jetpack_migration 2 jp_img_sitemap 2 jp_sitemap 2 jp_sitemap_master 2 nav_menu_item 23 page 21 post 7 product 50 product_variation 337 revision 101 scheduled-action 10 shop_coupon 7 shop_order 220 shop_order_refund 4 wl_convertedsales 1 wl_emaillog 98 wpcf7_contact_form 1 Segurança Conexão segura (HTTPS): Esconder erros para visitantes Plugins ativados (36) Advanced Custom Fields por Elliot Condon – 5.7.12 Akismet Anti-Spam por Automattic – 4.1.1 Contact Form 7 por Takayuki Miyoshi – 5.1.1 Disable Gutenberg por Jeff Starr – 1.8.1 Improved Product Options for WooCommerce por 7VX LLC, USA CA – 4.6.3 Instagram Slider Widget por jetonr – 1.4.3 Jetpack por WordPress.com por Automattic – 7.3.0 WPBakery Page Builder por Michael M - WPBakery.com – 995.5.2 Tradução (Loco) por Tim Whitlock – 2.2.2 Mailchimp for WooCommerce por Mailchimp – 2.1.15 – Não testado com a versão ativa do WooCommerce PayPal for WooCommerce por Angell EYE – 1.5.7 – Não testado com a versão ativa do WooCommerce Checkout Transparente do PayPal por PayPal – 1.6.4 – Não testado com a versão ativa do WooCommerce Porto Theme - Functionality por P-Themes – 1.3.0 Really Simple SSL por Rogier Lankhorst, Mark Wolters – 3.1.5 Remove Query Strings From Static Resources por Speed Up My Website – 1.4 Stream por XWP – 3.2.3 WooCommerce Melhorias no Gerenciamento de Estoque das Variações por Luiz Paulo Bills – 1.0.1 – Não testado com a versão ativa do WooCommerce WooCommerce Dynamic Pricing & Discounts por RightPress – 2.2.8 – Não testado com a versão ativa do WooCommerce WC Simulador de Frete por Fernando Acosta – 1.6.11 – Não testado com a versão ativa do WooCommerce WooCommerce Preço das Variações à Nível de Produto Pai por Luiz Paulo Bills – 1.0.0 – Não testado com a versão ativa do WooCommerce SUMO Waitlist por Fantastic Plugins – 1.4 – Não testado com a versão ativa do WooCommerce WooCommerce Better Shipping Calculator for Brazil por Luiz Paulo Bills – 2.0.0 – Não testado com a versão ativa do WooCommerce WooCommerce Correios por Claudio Sanches – 3.7.2 WooCommerce Extra Checkout Fields for Brazil por Claudio Sanches – 3.6.1 – Não testado com a versão ativa do WooCommerce Integração do Google Analytics com o WooCommerce por WooCommerce – 1.4.9 WooCommerce Boleto PagHiper por Henrique Cruz, PagHiper – 1.2.5.3 – Não testado com a versão ativa do WooCommerce WooCommerce PagSeguro por Claudio Sanches – 2.13.1 – Não testado com a versão ativa do WooCommerce WooCommerce Product SKU Generator por SkyVerge – 2.3.4 – Não testado com a versão ativa do WooCommerce WOOF - WooCommerce Products Filter por realmag777 – 2.1.9 – Não testado com a versão ativa do WooCommerce WooCommerce por Automattic – 3.6.2 WP Fastest Cache por Emre Vona – 0.8.9.3 WP Sitemap Page por Tony Archambeau – 1.6.1 ZHF Ecommerce por ZHF Mídia Digital – 1.6.2 ZHF Painel por ZHF Mídia Digital – 3.8.4 ZHF Porto por ZHF Mídia Digital – 1.4.3 ZHF Ecommerce - Mostrar endereço da loja no checkout e nos e-mails por Luiz Bills – 1.0.0 Plugins inativos (2) ATUM Inventory Management for WooCommerce por Stock Management Labs™ – 1.5.8.1 Facebook for WooCommerce por Facebook – 1.9.12 – Não testado com a versão ativa do WooCommerce Configurações API habilitada: Forçar SSL: – Moeda BRL (R$) Posição da moeda left Separador de milhares . Separador decimal , Número de casas decimais 2 Taxonomias: Tipos de produto external (external), grouped (grouped), simple (simple), variable (variable) Taxonomias: Visibilidade de produto 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) Conectado ao WooCommerce.com: Páginas do WooCommerce Base da loja: #207 - /shop/ Carrinho: #208 - /carrinho/ Finalizar compra: #209 - /checkout/ Minha conta: #210 - /minha-conta/ Termos e condições: #3 - /politica-de-privacidade/ Tema Nome: Porto Child Versão: 1.1 URL do autor: http://www.portotheme.com/ Tema filho: Nome do tema ascendente: Porto Versão do tema ascendente: 4.9.2 URL do autor do tema ascendente: http://www.portotheme.com/ Suporte do WooCommerce: Modelos Substituições porto/woocommerce/archive-product.php, porto/woocommerce/cart/cart-shipping.php versão 3.5.0 está desatualizado. A versão do core é 3.6.0, porto/woocommerce/cart/cart-totals.php, porto/woocommerce/cart/cart.php, porto/woocommerce/cart/cross-sells.php, porto/woocommerce/cart/mini-cart.php, porto/woocommerce/cart/proceed-to-checkout-button.php, porto/woocommerce/cart/shipping-calculator.php, porto/woocommerce/checkout/form-billing.php versão 3.0.9 está desatualizado. A versão do core é 3.6.0, porto/woocommerce/checkout/form-checkout.php, porto/woocommerce/checkout/form-coupon.php, porto-child/woocommerce/checkout/form-login.php, porto/woocommerce/checkout/form-pay.php, porto/woocommerce/checkout/payment.php, porto/woocommerce/checkout/review-order.php, porto/woocommerce/content-product.php versão 3.4.0 está desatualizado. A versão do core é 3.6.0, porto/woocommerce/content-product_cat.php, porto/woocommerce/content-single-product.php versão 3.4.0 está desatualizado. A versão do core é 3.6.0, porto/woocommerce/content-widget-product.php versão 3.5.2 está desatualizado. A versão do core é 3.5.5, porto/woocommerce/global/form-login.php versão 3.3.0 está desatualizado. A versão do core é 3.6.0, porto/woocommerce/global/quantity-input.php versão 3.4.0 está desatualizado. A versão do core é 3.6.0, porto/woocommerce/global/wrapper-start.php, porto/woocommerce/loop/add-to-cart.php, porto/woocommerce/loop/loop-end.php, porto/woocommerce/loop/loop-start.php, porto/woocommerce/loop/no-products-found.php, porto/woocommerce/loop/orderby.php versão 3.3.0 está desatualizado. A versão do core é 3.6.0, porto/woocommerce/loop/pagination.php, porto/woocommerce/loop/rating.php versão 3.0.0 está desatualizado. A versão do core é 3.6.0, porto/woocommerce/loop/sale-flash.php, porto/woocommerce/myaccount/downloads.php, porto/woocommerce/myaccount/form-add-payment-method.php, porto/woocommerce/myaccount/form-edit-account.php, porto/woocommerce/myaccount/form-edit-address.php versão 3.4.0 está desatualizado. A versão do core é 3.6.0, porto/woocommerce/myaccount/form-login.php versão 3.5.0 está desatualizado. A versão do core é 3.6.0, porto/woocommerce/myaccount/form-lost-password.php, porto/woocommerce/myaccount/form-reset-password.php versão 3.5.0 está desatualizado. A versão do core é 3.5.5, porto/woocommerce/myaccount/lost-password-confirmation.php, porto/woocommerce/myaccount/my-account.php, porto/woocommerce/myaccount/my-address.php, porto/woocommerce/myaccount/my-downloads.php, porto/woocommerce/myaccount/my-orders.php, porto/woocommerce/myaccount/orders.php, porto/woocommerce/myaccount/payment-methods.php, porto/woocommerce/myaccount/view-order.php, porto/woocommerce/order/form-tracking.php versão 3.4.0 está desatualizado. A versão do core é 3.6.0, porto/woocommerce/order/order-details.php, porto/woocommerce/order/tracking.php, porto/woocommerce/single-product/add-to-cart/simple.php, porto/woocommerce/single-product/add-to-cart/variable.php versão 3.4.1 está desatualizado. A versão do core é 3.5.5, porto/woocommerce/single-product/meta.php, porto/woocommerce/single-product/product-attributes.php versão 3.1.0 está desatualizado. A versão do core é 3.6.0, porto/woocommerce/single-product/product-image.php, porto/woocommerce/single-product/product-thumbnails.php, porto/woocommerce/single-product/rating.php versão 3.1.0 está desatualizado. A versão do core é 3.6.0, porto/woocommerce/single-product/related.php, porto/woocommerce/single-product/review-meta.php, porto/woocommerce/single-product/review-rating.php versão 3.1.0 está desatualizado. A versão do core é 3.6.0, porto/woocommerce/single-product/review.php, porto/woocommerce/single-product/sale-flash.php, porto/woocommerce/single-product/short-description.php, porto/woocommerce/single-product/tabs/tabs.php, porto/woocommerce/single-product/title.php, porto/woocommerce/single-product/up-sells.php, porto/woocommerce/single-product-reviews.php versão 3.5.0 está desatualizado. A versão do core é 3.6.0 Modelos desatualizados: Aprenda como atualizar Action Scheduler Action Status Count Oldest Scheduled Date Newest Scheduled Date Complete 10 2019-05-07 18:37:55 -0300 2019-05-07 18:38:20 -0300 Pending 0 – – Canceled 0 – – In-progress 0 – – Failed 0 – – ```
odirlon commented 5 years ago

Completing post:

The only thing that resolves is the update of the product, change of the volume in stock of the variation or in the last cases recadastro of the product.

AkshayRathod10 commented 5 years ago

i am getting the exact same error. @odirlon did you find any solution?

odirlon commented 5 years ago

Not yet, unfortunately.

In your case, are all variations priced?

AkshayRathod10 commented 5 years ago

@odirlon Yes. All variations are priced. Screenshot 2019-05-08 12:48:58

dnavarroBIG commented 5 years ago

I have the same problem. All products in my shop are variation products and since lasts updates i'm getting this same problem.

I have detected it happens when someone buys in my shop.

When someone buys, a random product of my shop instantly chages to "Out of stock"

wakkermedia commented 5 years ago

Follow this!

ivanodonoghue commented 5 years ago

Same problem. Disabled all plugs but woo, switched theme, even rolled back to woo 3.6.8 - no improvement. Only restoring from point in time backup fixed it indicating problem is in database.

odirlon commented 5 years ago

Hey gay! try this: Go to Products > All > Kick Edit

Change the "Stock status" for "In Stock".

odirlon commented 5 years ago

@ivanodonoghue, Anyway, this is not problem solving, this is palliative. I have not yet discovered the source of the problem.

dnavarroBIG commented 5 years ago

I had a backup with 3.5.8. Happened just once, but I'm not sure if it's the same problem. If u can move to this version just do it while someone fixes this bug

ivanodonoghue commented 5 years ago

@dnavarroBIG simply replacing 3.6.x with 3.5.8 version of plugin didn't work for me, I needed to do a full restore, indicating that the database has a part to play.

millionleaves commented 5 years ago

I am able to fix individual products manually by disabling stock management for each variation, saving the changes, then re-enabling stock management and saving the changes again.

The issue as I see it is that, in situations where the stock display on the front end is incorrect, the wc_product_meta_lookup (which is used to build the front end display of the product) is incorrect and doesn't reflect the data in the postmeta table unless you follow these steps. Simply clearing that table and regenerating the data doesn't make any difference.

odirlon commented 5 years ago

Hello @millionleaves!

I am able to fix individual products manually by disabling stock management for each variation, saving the changes, then re-enabling stock management and saving the changes again.

R: I do the same and also fixes the problem. Another solution is to add a drive in the variations, save and then subtract the added drive and save again, also resolves.

The issue as I see it is that, in situations where the stock display on the front end is incorrect, the wc_product_meta_lookup (which is used to build the front end display of the product) is incorrect and doesn't reflect the data in the postmeta table unless you follow these steps. Simply clearing that table and regenerating the data doesn't make any difference.

R: Yes, All the tricks like recalculating the terms, generating the table, or clearing client sessions does nothing.

The most bizarre of all is that this is happening in several clients, with different situations, plugins, hosting, etc ...

KrystianErgotopia commented 5 years ago

I want to add another issue we noticed regarding this out-of-stock problem. The issued archive pages in our case had wrong classes added to the see pic: 2019-05-27_08h22_05

odirlon commented 5 years ago

Guys, I created a page to punitor the products that have this problem.

What's the downside: A public page will be created with all the products of your ecommerce, I recommend creating a very complex link and disable the indexing of thefts.

Let's take the steps:

01- Create a page-checkstock.php with the following code: https://github.com/odirlon/checkstock-error

02- Change the line 84 to receive the notifications.

03- Create a page with a complicated slug like this: "check-stock-2452233213321653441" and use the template created in the previous step.

04- Create a cron to check the page from time to time on the site: https://www.easycron.com/user

05- Ready, now whenever a stock bugar you will receive an email notifying you, or if you want to see if the site has an error simply access the page you created.

Remember to remove the cache from this page.

marcosvrezende commented 5 years ago

Hello guys,

Anyone know if the issue has been resolved in the new update? 3.6.4

This is a big problem for anyone who manages 50 more customer shops.

Thank you very much!

millionleaves commented 5 years ago

@odirlon Looking at my postmeta table in the database, I've realised that some of my products have _manage_stock set to 1/0 rather than yes/no. I don't know how they got like that, but these are the products that are causing the issue - when I fix them as described in my earlier comment, it sets them to yes and the issue goes away.

So ... either there is something wrong with my site, or there is a specific historical reason they are like that that the latest version of WooCommerce doesn't take account of when building the wc_product_meta_lookup table.

connexgroup commented 5 years ago

I believe this is related to the way the product is being setup.

From the research I've done, if you create a product as a standard product and save it, and then change it to a variable product it seems to be creating this issue. I've had this on more than one site.

millionleaves commented 5 years ago

Thanks @connexgroup. That makes sense, based on the site I'm thinking of. This issue feels like something that should be dealt with in WooCommerce core through a bug fix, but at least I now know I fix it myself by running a database update on any sites exhibiting this issue.

odirlon commented 5 years ago

Hey! Cool this, I'm excited now! I'll do simulations to see this happen.

marcosvrezende commented 5 years ago

Hi guys,

This here solved for me: https://wordpress.org/support/topic/variable-product-display-as-out-of-stock-when-there-is-stock/#post-11584624

a practical and fast solution to solve all the products in one go. then we should not have any more problems! Thank you so much!

vedanshujain commented 4 years ago

Looks like this was addressed by #23534, and a workaround for stores who already have updated lookup tables when the bug was present is to regenerate them again by WooCommerce > Status > Tools and regenerating product lookup tables (note: this might take some time depending upon the number of products in the store)_. I am closing the issue, but please comment if this is still happening with the latest version and I will reopen it again.

TimothyWildgust commented 4 years ago

I had the same problem. What I did to fix it was bulk edit the products and even tho they said out of stock I selected out of stock and hit update. After that I bulk edited again and set them to in stock. It worked for me 👍

tophr commented 3 years ago

I'm running into this issue too (products with in stock variations aren't showing in search or catalog when "Hide out of stock items from the catalog" is enabled) on a site with 8k+ products with variations running into the 50k+ territory. Completely wiping wc_product_meta_lookup and running regenerate Product lookup tables doesn't fix.

Are there any other hooks I could run to update product data? Strangely, I can fix an individual product by flipping the Product data dropdown to "Simple product", going to Inventory, changing Stock status to "out of stock", changing the dropdown back to Variable product, and hitting Update. Doing that for 8,000 products isn't really feasible however.