gpt4 book ai didi

php - WooCommerce 产品在实际上没有缺货时显示 “Out of stock” 消息

转载 作者:IT老高 更新时间:2023-10-28 12:59:10 26 4
gpt4 key购买 nike

遇到产品随机显示的客户网站问题

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

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

当我进入 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 添加元 key _manage_stock 并将其设置为 no(在我们的一些工作产品中观察到)
  • 手动插入到 wp_postmeta 添加元键 '_stock' 并将其设置为 0(正如在我们拥有的一些工作产品中所观察到的)
  • 比较了点击更新按钮前后产品的 postmeta,观察是否有任何改变会导致问题...没有
  • 没有开启缓存
  • 使用 XDebug 跟踪 variable.php 中的 $available_variations 变量和class-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] =>
)

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

2014 年 10 月 23 日更新

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

最佳答案

我遇到了同样的问题,我想我已经解决了。我使用 CSV 导入/导出套件来导出我的所有变体。您会注意到 stock 设置为 0,而它的值应该是 null

你有两个选择:

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

关于php - WooCommerce 产品在实际上没有缺货时显示 “Out of stock” 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24639288/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com