Woocommerce产品在没有实际缺货的情况下显示"缺货"消息

Ian*_*Ian 40 php mysql wordpress woocommerce

产品随机显示的客户网站存在问题

"该产品目前无货,无法使用."

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

当我进入WordPress管理员并单击产品的更新按钮(不更改任何内容),然后消息消失,"添加到购物车"按钮显示应该.不幸的是,这个问题在未来会重复出现并修复它我必须再次更新产品(同时点击WooCommerce设置中的更新暂时解决了这个问题).

我需要找到一种永久解决这个问题的方法,这样它就不会自行恢复.

网站详情:

  • 使用WordPress 3.9.1
  • WooCommerce 2.1.12
  • PHP 5.3.10(也在本地尝试使用5.5.10)

我试过的

  • 删除所有插件,但WooCommerce
  • 改变主题(尝试了所有标准的WordPress主题和一些WooThemes主题无济于事)
  • 更新了WooCommerce(它是v 2.1.5)
  • 手动插入wp_postmeta添加元键_manage_stock并将其设置为no(在我们的一些工作产品中观察到)
  • 手动插入wp_postmeta添加元键'_stock'并将其设置为0(如我们所拥有的一些工作产品中所观察到的)
  • 比较点击更新按钮之前和之后产品的postmeta,以观察是否有任何改变会导致问题......没有
  • 没有启用缓存
  • 二手XDebug的跟踪$available_variations变量variable.phpclass-wc-ajax.phpclass-wc-product-variable.php.

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

老实说,在这一点上,我很茫然.我认为这个问题出现在任何一个类中,但我无法分辨.

还有其他人有这个问题吗?任何解决这个问题的方法,所以我不必为这个客户端不断更新产品.

链接到缺货的产品(截至发布时)http://highlandsministriesonline.org/product/basement-tapes/resentment-in-the-church-135/

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

错误日志 我在产品变体类中添加了错误日志.下面是结果:

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

正常运行的产品示例:

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] => 
)
Run Code Online (Sandbox Code Playgroud)

潜在的后续步骤我的下一个想法是,如果我不能解决这个问题,那就是编写一个脚本,每晚会通过并更新网站上的每个产品(因为临时修复似乎适用于我们的至少24个).虽然如果我可以节省一些时间,我宁可不要,如果其他人能够永久解决这个问题.

更新至2014年10月23日

尽管尝试下面的答案,这个问题仍然存在.我创建了一个日志插件,希望有助于跟踪缺货消息的频率,并希望有助于将消息与网站上发生的任何操作相关联.它目前是针对这个特定网站定制的,但我正在开发一个版本与大家分享,即使我找不到答案,也有人可以.

Zac*_*ell 7

我有同样的问题,我想我想出来了.我使用CSV导入/导出套件导出我的所有变体.您会注意到库存设置为0值应为null.

你有两个选择:

  1. 进入每个产品,点击变体标签并展开每个变体 - 取消选中"管理库存"复选框:在此输入图像描述
  2. 您可以在数据库上执行查找和替换,将0值替换为null.


Joe*_*Joe 6

我新创建的产品也遇到了同样的问题。但对我来说,答案更简单。

\n\n

我需要为每个变体输入 \xe2\x80\x9cRegular Price\xe2\x80\x9d 。
\n https://wordpress.org/support/topic/this-product-is-currently-out-of-stock-and-unavailable-4/

\n\n

我之前已经创建了我的属性。

\n\n

在“变体”下,对于我的产品,我必须确保选择 \xe2\x80\x9cAddvariations\xe2\x80\x9d。然后我单击了 \xe2\x80\x9cGo\xe2\x80\x9d 按钮。

\n\n

我需要为属性可能具有的每个不同选择创建一个变体。

\n\n

因此,对于我的颜色选项,我必须做出三种不同的变化(每种选择一种)。
\n然后我需要单击蓝色的 \xe2\x80\x9cExpand\xe2\x80\x9d 文本,并确保每个变体都有一个 Regular Price

\n\n

然后就成功了。\n在此输入图像描述

\n\n

(这也很有帮助: https: //docs.woocommerce.com/document/variable-product/

\n


O-m*_*kar 0

尝试删除产品并创建相同的产品,然后尝试我遇到同样的问题,它对我有用。甚至尝试重新安装 WooCommerce 2.1.12