如何使用優惠券代碼20 rs off和6%的稅率來計算在uoo commerce中創建訂單的線路總數。如何計算電子商務中的線路總數
$order = new WC_Order();
$order = wc_create_order($order_data);
$items = WC()->cart->get_cart();
foreach($items as $item => $values) {
$product_id = $values['product_id'];
$product = wc_get_product($product_id);
$quantity = (int)$values['quantity'];
$sale_price = $product->get_price();
$final_price = ?????
$price_params = array('totals' => array('subtotal' => $sale_price, 'total' => $final_price));
$order->add_product($product, $quantity,$price_params);
}
這裏我怎樣才能得到$ final_price?
使用WC_Cart :: calculate_totals(); –