首页 > 解决方案 > 未捕获的 ArgumentCountError:函数 wc_get_page_id() 的参数太少

问题描述

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

致命错误:未捕获的 ArgumentCountError:函数 wc_get_page_id() 的参数太少,在第 30 行的 /home/s3morder/public_html/wp-content/themes/Intranet Theme/woocommerce/cart/cart-empty.php 中传递了 0,而预期为 1在 /home/s3morder/public_html/wp-content/plugins/woocommerce/includes/wc-page-functions.php:45 堆栈跟踪:#0 /home/s3morder/public_html/wp-content/themes/Intranet Theme/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): include('/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 行

提前致谢!

标签: phpwordpresstemplateswoocommercewordpress-theming

解决方案


我发现 empty-cart.php 中有一个额外的函数我没有摆脱,一旦我缩小了错误开始的位置,我就知道我需要摆脱什么,cart-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.是完美的!我希望这可以帮助别人!


推荐阅读