【发布时间】:2020-06-21 07:54:19
【问题描述】:
我知道我的问题的标题可能听起来令人困惑,因此,请您查看所附图片以进行澄清。
我已经尝试过自己完成这项工作,但没有成功。测试我的代码在结帐页面上没有任何改变。没有变化,没有错误,没有通知 - 什么都没有。
到目前为止我的代码:
add_filter( 'woocommerce_cart_item_price', 'item_price_and_total_price', 10, 3 );
function item_price_and_total_price( $price, $cart_item, $cart_item_key ) {
foreach( WC()->cart->get_cart() as $cart_item ){
$item = $cart_item['data']->get_id();
}
// item price title
$price_title = 'Item price';
// item price (this should not change as the qty changes)
$price_per_item = wc_price( $item ) . ' per item';
// total item price (cost) as the qty changes
$total_item_price = // don't know how to get it
// return everything
$price = $price_title . '<br />' . $price_per_item . '<br />' . $total_item_price;
return $price;
}
谁能告诉我哪里出错了?
【问题讨论】:
标签: php wordpress woocommerce checkout price