【问题标题】:Uncaught ArgumentCountError: Too few arguments to function wc_get_page_id()未捕获的 ArgumentCountError:函数 wc_get_page_id() 的参数太少
【发布时间】:2018-10-11 19:11:59
【问题描述】:

我的 WooCommerce 购物车页面为空时出现此错误,我该如何消除此错误消息?

致命错误:未捕获的 ArgumentCountError:参数太少 函数 wc_get_page_id(), 0 传入 /home/s3morder/public_html/wp-content/themes/Intranet Theme/woocommerce/cart/cart-empty.php 在第 30 行,正好是 1 预计在 /home/s3morder/public_html/wp-content/plugins/woocommerce/includes/wc-page-functions.php:45 堆栈跟踪:#0 /home/s3morder/public_html/wp-content/themes/Intranet 主题/woocommerce/cart/cart-empty.php(30): wc_get_page_id() #1 /home/s3morder/public_html/wp-content/plugins/woocommerce/includes/wc-core-functions.php(211): 包括('/home/s3morder/...')#2 /home/s3morder/public_html/wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-cart.php(85): wc_get_template('cart/cart-empty...') #3 /home/s3morder/public_html/wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php(76): WC_Shortcode_Cart::output(Array) #4 /home/s3morder/public_html/wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php(89): WC_Shortcodes::shortcode_wrapper(Array) #5 /home/s3morder/public_html/wp- in /home/s3morder/public_html/wp-content/plugins/woocommerce/includes/wc-page-functions.php 在第 45 行

提前致谢!

【问题讨论】:

  • 您是否修改了购物车代码?该错误仅表明函数 wc_get_page_id() 调用了 0 个参数,但需要 1 个参数
  • 如果不是,请在第 30 行向我们展示来自 /Intranet Theme/woocommerce/cart/cart-empty.php 的代码(向我们展示超过第 30 行)
  • 所以模板文件cart/cart-empty.php位于你的"Intranet Theme"主题文件夹是有罪的,你应该联系主题作者支持线程,因为我们不处理 StackOverFlow 中的支持
  • 感谢@LoicTheAztec 的帮助,我弄清楚了它是什么并让它正常工作。
  • 感谢@Tobias 的帮助。

标签: php wordpress templates woocommerce wordpress-theming


【解决方案1】:

我发现 empty-cart.php 中有一个额外的功能我没有摆脱,一旦我缩小了错误的开始位置,我就知道我需要摆脱什么,购物车- empty.php 文件如下。

<?php

   if ( ! defined( 'ABSPATH' ) ) {
      exit; // Exit if accessed directly
   }
?>
<div class="text-center">
   <?php do_action( 'woocommerce_cart_is_empty' );?>
</div>

并且给出的回复是Your cart is currently empty.,这是完美的! 我希望这对某人有帮助!

【讨论】:

    猜你喜欢
    • 2019-06-01
    • 2018-06-26
    • 1970-01-01
    • 1970-01-01
    • 2022-01-07
    • 2018-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多