【发布时间】:2017-04-19 12:51:24
【问题描述】:
如果我使用 20 rs off 的优惠券代码和 6% 的税收,我如何计算在 woo 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();
标签: php wordpress woocommerce