【发布时间】:2018-07-04 12:05:50
【问题描述】:
我最初需要从系统中的单个预订中将 x 金额 [trip_price] 的数组总和相加。这是一个单一的预订,在同一个预订中包含 2 种类型的金额。
总金额为$booking_total = $post_metas['fcb_booking_total'][0];,这反过来又产生了一个静态数字,因此当对预订进行更改时,价格永远不会更新。
$get_price = $wpdb->get_results("select trip_price from fcb_booking where order_id = " . $order_id . " order by start_date_time asc");
print_r($get_price);
Array
(
[0] => stdClass Object
(
[trip_price] => 0
)
[1] => stdClass Object
(
[trip_price] => 5000
)
)
编辑。
从下面的答案中我使用了这个。这使得更新将价格更改为用户的新价格等。这需要在电子邮件确认中显示。
$get_price = $wpdb->get_results("select trip_price from fcb_booking where order_id = " . $order_id . " order by start_date_time asc");
$booking_total = 0;
foreach($get_price as $key => $value) {
$booking_total += $value->trip_price;
};
如果用户在网站上支付了 100% 或 50% 的选项、任何管理员折扣和 5% 的额外费用,我用它来返回价格
$total = $booking_total + $extra_total;
$total = $total * 1.05;
if($need_to_pay){
if($amounttopay == 50){
$total = $total / 2;
}
}
if($admin_discount>0){
$total = $total - $admin_discount;
}
return $total;
【问题讨论】:
标签: php