How to calculate line total in wocommerce

How can i calculate the line total for creating order in woo commerce if i am using coupon code of 20 rs off and and having tax of 6%.

$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);
}

Here how can i get $final_price ??

Read more here: How to calculate line total in wocommerce

Leave a Reply

Your email address will not be published. Required fields are marked *