php - 未捕获的 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 行
提前致谢!
解决方案
我发现 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.
是完美的!我希望这可以帮助别人!
推荐阅读
- sqlalchemy - 集成 Apache Superset 和 Apache Drill
- arrays - 一个数组包含 N 个排序错误的子集。在数组中查找元素 X
- reactjs - Typescript 中的泛型类型
- php - 如何按包含日期的元素从最新到最旧对 3 维数组进行排序
- sql - 内连接与不同表中的所有相似数据
- javascript - 在JS中获取从今天起正好6天前的日期
- c - 为什么这不删除用户命令末尾的“&”?
- jquery - Jquery - 为多个表添加相同的事件
- kdb - 仅使用 Q 更新键控 KDB+ 表中的匹配记录
- java - 如何传递特定字符串以从数据库android获取特定值