我正在使用以下代码来更新购物车页面,其中包含用于预订产品的人员数量:
// Add "Persons" to replace cart quantity for bookable products
add_filter( 'woocommerce_cart_item_quantity', 'replace_cart_quantity_for_bookings', 20, 3 );
function replace_cart_quantity_for_bookings( $product_quantity, $cart_item_key, $cart_item ){
// Check that is a bookable product
if( isset($cart_item['booking']) ){
$product_quantity = '<span style="text-align: center; display:inline-block;">'.$cart_item['booking']['Persons'].'<br>
<small>(' . __('persons','woocommerce') . ')</small><span>';
}
return $product_quantity;
}
但是此代码不起作用并显示该错误:
注意:未定义的索引:Persons in
/home/www/wp-content/themes/my-child-theme/functions.php
一些帮助将不胜感激。