WooCommerce产品在实际没有缺货时显示“缺货”消息

2022-08-30 10:38:59

客户网站出现问题,其中产品随机显示

“此产品目前缺货,缺货。

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

当我进入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_stockno
  • 手动插入到wp_postmeta添加元键“_stock”并将其设置为(如我们在一些工作产品中观察到的那样)0
  • 比较了点击更新按钮之前和之后产品的后期版本,以观察是否有任何更改会导致问题...无
  • 未打开缓存
  • 使用 XDebug 跟踪 和 中的变量。$available_variationsvariable.phpclass-wc-ajax.phpclass-wc-product-variable.php

在调试时,我注意到在正在工作的产品中,变量包含2个数组,其中填充了产品信息,但是在没有填充产品信息的产品上,它是一个空数组(这导致缺货消息显示为由 )。单击更新按钮,然后跟踪变量,可以正确显示信息。$available_variationsvariable.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] => 
)

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

更新于 2014 年 10 月 23 日

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


答案 1

我有同样的问题,我想我想通了。我使用CSV导入/导出套件来导出我的所有变体。您会注意到,股票设置为其值应为 的时间。0null

您有两种选择:

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

答案 2

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

我需要为每个变体输入“正常价格”。
https://wordpress.org/support/topic/this-product-is-currently-out-of-stock-and-unavailable-4/

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

在“变体”下,对于我的产品,我必须确保选择了“添加变体”。然后我点击了“开始”按钮。

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

因此,对于我的颜色选项,我必须制作三种不同的变体(每个选项一个)。
然后,我需要单击蓝色的“展开”文本,并确保每个变体都有常规价格

然后它起作用了。enter image description here

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


推荐