WooCommerce产品在实际上没有缺货时显示“缺货"消息 [英] WooCommerce products showing “Out of stock” message when not actually out of stock

查看:235
本文介绍了WooCommerce产品在实际上没有缺货时显示“缺货"消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

产品随机显示的客户网站出现问题

Having an issue with a client website where products are randomly displaying

该产品目前无货,不可用."

"This product is currently out of stock and unavailable."

问题是我们没有打开库存跟踪,所有产品应该一直都在库存中.

当我进入WordPress管理员并单击产品的更新按钮(不进行任何更改)时,该消息消失,并且按应显示的添加到购物车"按钮.不幸的是,这个问题以后会在这些项目上重演,要解决此问题,我必须再次更新产品(也可以在WooCommerce设置中单击更新"以暂时解决此问题).

When I go into the WordPress admin and click the update button for the product (without changing anything) and then the message goes away and the "Add to Cart" button displays as it should. Unfortunately, the issue repeats itself on these items in the future and to fix it I have to update the product again (also clicking update in the WooCommerce settings temporarily solves the problem).

我需要找到一种永久解决此问题的方法,以便它不会自动还原.

I need to find a way to fix this problem permanently so it doesn't revert itself.

网站详细信息:

  • 使用WordPress 3.9.1
  • WooCommerce 2.1.12
  • PHP 5.3.10(也在5.5/10本地试用)

我尝试过的事情

  • 删除所有插件,但WooCommerce
  • 不断变化的主题(尝试了所有标准WordPress主题和一些WooThemes主题都无济于事)
  • 更新了WooCommerce(版本为2.1.5)
  • 手动插入到wp_postmeta中,添加元键_manage_stock并将其设置为no(在我们拥有的某些工作产品中已经观察到)
  • 手动插入到wp_postmeta中,添加元密钥'_stock'并将其设置为0(在我们拥有的某些工作产品中已经观察到)
  • 在单击更新"按钮之前和之后比较了产品的后修饰,以查看是否有任何更改会导致问题...什么都没有
  • 未打开缓存
  • 使用XDebug跟踪variable.php中的$available_variations变量,并 class-wc-ajax.phpclass-wc-product-variable.php.
  • Removing all plugins but WooCommerce
  • Changing themes (tried all standard WordPress themes and a few WooThemes themes to no avail)
  • Updated WooCommerce (it was v 2.1.5)
  • Manually inserted to wp_postmeta adding the meta key _manage_stock and set it to no (as observed in some of the working products we have)
  • Manually inserted to wp_postmeta adding the meta key '_stock' and set it to 0 (as observed in some of the working products we have)
  • Compared the postmeta of the product before and after clicking the update button to observe if anything had changed that would cause the problem...nothing
  • No caching is turned on
  • Used XDebug to track the $available_variations variable in variable.php and class-wc-ajax.php and class-wc-product-variable.php.

调试时,我注意到在工作中的产品中,$available_variations变量包含2个数组,其中填充了产品信息,但是在没有产品的产品上,它是一个空数组(导致出现缺货信息显示为由variable.php服务).单击更新按钮,然后跟踪变量可以正确显示信息.

When debugging I noticed that in products that were working the $available_variations variable contained 2 arrays filled with product information, however on the products that didn't, it was an empty array (which results in the out of stock message being displayed as served by variable.php). Clicking the update button and then tracking the variable shows the information correctly.

老实说,这时我很茫然.我认为问题出在这两个类中的某个地方,但我无法分辨.

Honestly at this point I'm at a loss. I think the issue is somewhere in either of the classes, but I can't tell.

还有其他人对此有疑问吗?可以通过任何方式解决此问题,因此我不必继续为此客户端更新产品.

Has anyone else had issues with this? Any way around this issue so I don't have to keep updating products for this client.

链接到缺货的产品(发布时)

Link to product that is out of stock (as of posting) http://highlandsministriesonline.org/product/basement-tapes/resentment-in-the-church-135/

链接到显示正确的产品 http://highlandsministriesonline.org/product/basement-tapes/bt0111-church-at-corinth-i/

Link to product that is displaying correctly http://highlandsministriesonline.org/product/basement-tapes/bt0111-church-at-corinth-i/

错误日志 我向产品变体类添加了错误日志.结果如下:

Error Log I added an error log to the product variation class. Heres the result:

对于带有缺货"消息的产品,日志中不显示任何内容.

For products with the "out of stock" message, nothing displays in the log.

可以正常运行的产品的示例:

An example of a product that function correctly:

WC_Product_Variation Object
(
    [variation_id] => 1310
    [parent] => WC_Product_Variable Object
        (
            [children] => Array
                (
                    [0] => 1311
                    [1] => 1310
                )

            [total_stock] => 
            [id] => 1308
            [post] => WP_Post Object
                (
                    [ID] => 1308
                    [post_author] => 1
                    [post_date] => 2012-04-03 14:29:42
                    [post_date_gmt] => 2012-04-03 18:29:42
                    [post_content] => This audio presentation on homeschooling is a Basement Tape conversation on homeschooling.
<h2>What are The Basement Tapes?</h2>
<em>The Basement Tapes</em> are conversations between Dr. R.C. Sproul Jr., Rev. Laurence Windham, their friends and special guests, on subjects related to the "good life," a simple, separate, and deliberate life, lived out for the glory of God and for the building of His Kingdom.

You might even say that the Basement Tapes serve to help us develop a Christian worldview. Started in 2002, we now have over #140 conversations on all areas of life that we are seeking to think biblically about so that we might take dominion over them for the King and His kingdom.

<strong>Format: Available in both CD and MP3</strong>

<strong>Length: Sixty minutes</strong>
                    [post_title] => Basement Tape #109: Homeschooling Redux
                    [post_excerpt] => It's been 108 weeks since we last talked about the subject of homeschooling our children. Our tykes have grown into teenagers. What have we learned in the past nine years? What has changed? What remains the same is that homeschooling means discipleship; passing down your most important convictions to your children and teaching them our holy religion.
                    [post_status] => publish
                    [comment_status] => open
                    [ping_status] => closed
                    [post_password] => 
                    [post_name] => bt0109-homeschooling-reducks
                    [to_ping] => 
                    [pinged] => 
                    [post_modified] => 2014-07-07 11:08:46
                    [post_modified_gmt] => 2014-07-07 15:08:46
                    [post_content_filtered] => 
                    [post_parent] => 0
                    [guid] => http://50.57.190.158/?post_type=product&#038;p=1308
                    [menu_order] => 0
                    [post_type] => product
                    [post_mime_type] => 
                    [comment_count] => 0
                    [filter] => raw
                )

            [product_type] => variable
        )

    [variation_data] => Array
        (
            [attribute_pa_audio-options] => mp3-download
        )

    [variation_has_length] => 
    [variation_has_width] => 
    [variation_has_height] => 
    [variation_has_weight] => 
    [variation_has_stock] => 
    [variation_has_sku] => 1
    [variation_shipping_class] => 
    [variation_shipping_class_id] => 
    [variation_has_tax_class] => 
    [variation_has_downloadable_files] => 1
    [id] => 1308
    [post] => WP_Post Object
        (
            [ID] => 1308
            [post_author] => 1
            [post_date] => 2012-04-03 14:29:42
            [post_date_gmt] => 2012-04-03 18:29:42
            [post_content] => This audio presentation on homeschooling is a Basement Tape conversation on homeschooling.
<h2>What are The Basement Tapes?</h2>
<em>The Basement Tapes</em> are conversations between Dr. R.C. Sproul Jr., Rev. Laurence Windham, their friends and special guests, on subjects related to the "good life," a simple, separate, and deliberate life, lived out for the glory of God and for the building of His Kingdom.

You might even say that the Basement Tapes serve to help us develop a Christian worldview. Started in 2002, we now have over #140 conversations on all areas of life that we are seeking to think biblically about so that we might take dominion over them for the King and His kingdom.

<strong>Format: Available in both CD and MP3</strong>

<strong>Length: Sixty minutes</strong>
            [post_title] => Basement Tape #109: Homeschooling Redux
            [post_excerpt] => It's been 108 weeks since we last talked about the subject of homeschooling our children. Our tykes have grown into teenagers. What have we learned in the past nine years? What has changed? What remains the same is that homeschooling means discipleship; passing down your most important convictions to your children and teaching them our holy religion.
            [post_status] => publish
            [comment_status] => open
            [ping_status] => closed
            [post_password] => 
            [post_name] => bt0109-homeschooling-reducks
            [to_ping] => 
            [pinged] => 
            [post_modified] => 2014-07-07 11:08:46
            [post_modified_gmt] => 2014-07-07 15:08:46
            [post_content_filtered] => 
            [post_parent] => 0
            [guid] => http://50.57.190.158/?post_type=product&#038;p=1308
            [menu_order] => 0
            [post_type] => product
            [post_mime_type] => 
            [comment_count] => 0
            [filter] => raw
        )

    [product_type] => variation
    [product_custom_fields] => Array
        (
            [_sku] => Array
                (
                    [0] => BT0109MP3
                )

            [_price] => Array
                (
                    [0] => 3
                )

            [_sale_price] => Array
                (
                    [0] => 
                )

            [_weight] => Array
                (
                    [0] => 
                )

            [_length] => Array
                (
                    [0] => 
                )

            [_width] => Array
                (
                    [0] => 
                )

            [_height] => Array
                (
                    [0] => 
                )

            [_stock] => Array
                (
                    [0] => 
                )

            [_thumbnail_id] => Array
                (
                    [0] => 0
                )

            [_virtual] => Array
                (
                    [0] => yes
                )

            [_downloadable] => Array
                (
                    [0] => yes
                )

            [_download_limit] => Array
                (
                    [0] => 
                )

            [_downloadable_files] => Array
                (
                    [0] => a:1:{s:32:"a0a87d43e69ed9de646ba479c252c9fb";a:2:{s:4:"name";s:29:"109-Homeschooling-Reducks.mp3";s:4:"file";s:113:"http://highlandsministriesonline.org/wp-content/uploads/woocommerce_uploads/2012/04/109-Homeschooling-Reducks.mp3";}}
                )

            [_regular_price] => Array
                (
                    [0] => 3
                )

            [_sale_price_dates_from] => Array
                (
                    [0] => 
                )

            [_sale_price_dates_to] => Array
                (
                    [0] => 
                )

            [_download_expiry] => Array
                (
                    [0] => 
                )

            [attribute_pa_audio-options] => Array
                (
                    [0] => mp3-download
                )

        )

    [sku] => BT0109MP3
    [downloadable_files] => a:1:{s:32:"a0a87d43e69ed9de646ba479c252c9fb";a:2:{s:4:"name";s:29:"109-Homeschooling-Reducks.mp3";s:4:"file";s:113:"http://highlandsministriesonline.org/wp-content/uploads/woocommerce_uploads/2012/04/109-Homeschooling-Reducks.mp3";}}
    [downloadable] => yes
    [virtual] => yes
    [sale_price_dates_from] => 
    [sale_price_dates_to] => 
    [price] => 3
    [regular_price] => 3
    [sale_price] => 
    [total_stock] => 0
    [dimensions] => 
)

潜在的后续步骤,如果无法解决此问题,我的下一个想法是编写一个脚本,该脚本将每晚进行一次更新网站上的每个产品的操作(因为该临时修复程序似乎可以正常工作)至少有24个是我们的).虽然如果我可以节省一些时间,但我不希望别人能够永久解决此问题.

Potential Next Steps My next thought if I cant get this resolved is to write a script that will go through and update each product on the website on a nightly basis (since the temporary fix seems to work for at least 24 ours). Though if I can save some of my time I'd rather not if someone else has been able to solve this issue permanently.

自2014年10月23日起更新

尽管尝试下面的答案,此问题仍在发生.我创建了一个日志记录插件,希望可以帮助跟踪缺货消息的出现频率,并希望将消息与网站上发生的任何操作相关联.目前已针对该特定网站进行了自定义,但是我正在开发一个与大家共享的版本,以便即使我找不到答案,也有人可以.

This issue is still occurring despite attempting the answers below. I have created a logging plugin to hopefully help track the frequency of the out of stock messages and hopefully help correlate the message with any actions taken place on the website. It's currently customized to this specific website, but I'm working on a version to share with you all so that even if I can't find the answer, someone can.

推荐答案

我遇到了同样的问题,我想我已经解决了.我使用CSV导入/导出套件导出了所有版本.您会注意到,当库存的值应为null时,会将其设置为0.

I had this same problem and I think I figured it out. I used the CSV Import/Export suite to export all of my variations. You'll notice that stock is set to 0 when it should have a value of null.

您在这里有两个选择:

  1. 进入每个产品,单击变体"选项卡并展开每个变体-取消选中管理库存"复选框:
  2. 您可以在数据库中执行查找和替换,将0值替换为null.

这篇关于WooCommerce产品在实际上没有缺货时显示“缺货"消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆