作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图吐出客户总(已完成)订单的生命周期成本。如果他们没有打折,我得到的值(value)等于金额,但是我已经将所有订单打折到 0 美元,因此如果他们根本没有支付任何钱,我使用这些数据是非常误导的。在对该订单应用退款和折扣后,我如何才能获得他们实际支付的值(value)?
function get_customer_total_order() {
$customer_orders = get_posts( array(
'numberposts' => - 1,
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'post_type' => array( 'shop_order' ),
'post_status' => array( 'wc-completed' )
) );
$total = 0;
foreach ( $customer_orders as $customer_order ) {
$order = wc_get_order( $customer_order );
$total += $order->get_total();
}
return $total;
}
最佳答案
这是我的最终功能:
// Get customer order total
function has_refunds( $order ) {
return sizeof( $order->get_refunds() ) > 0 ? true : false;
}
function get_customer_total_order() {
$customer_orders = get_posts( array(
'numberposts' => -1,
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'post_type' => array( 'shop_order' ),
'post_status' => array( 'wc-completed' )
) );
$total = 0;
foreach ( $customer_orders as $customer_order ) {
$order = wc_get_order( $customer_order );
if( has_refunds( $order ) ) {
}
else
{
$price = $order->get_total();
$discount = $order->get_total_discount();
$final = $price - $discount;
$total += $final;
}
}
return $total;
}
关于php - WooCommerce - 调整折扣和退款的客户生命周期订单成本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60962905/
我正在开发一个使用多个 turtle 的滚动游戏。玩家 turtle 根据按键命令在 Y 轴上移动。当危害和好处在 X 轴上移动时,然后循环并改变 Y 轴位置。我尝试定义一个名为 colliding(
我不明白为什么他们不接受这个作为解决方案,他们说这是一个错误的答案:- #include int main(void) { int val=0; printf("Input:- \n
我正在使用基于表单的身份验证。 我有一个注销链接,如下所示: 以及对应的注销方法: public String logout() { FacesContext.getCurren
在 IIS7 应用程序池中有一个设置 Idle-time out 默认是 20 分钟,其中说: Amount of time(in minutes) a worker process will rem
我是一名优秀的程序员,十分优秀!