E. Kostadinov E. Kostadinov - 5 months ago 65
PHP Question

WooCommerce get subtotal value from cart

I use the module for calculating delivery by local carrier, but the module do not calculate shipping costs to the total.
In the

wp-content/plugins/woocommerce/templates/order/order-details.php
I added the following code to take the amount of shipping and subtotal:

<? php $ a = array (
get_post_meta ($ order_id, 'Order_subtotal', true),
get_post_meta ($ order_id, 'Econt_Customer_Shipping_Cost', true));
?>
<tr class = "total-cost">
<th> <? php _e ( 'Total:', 'woocommerce'); ?> </ Th>
<Td> <? php echo array_sum ($ a); ?> <? php echo
get_woocommerce_currency_symbol (); ?> </ td>
</ tr>


As a result, I get only the value of
"Econt_Customer_Shipping_Cost"
, but not from
"Order_subtotal"
to get the total.
Please if someone can tell me what to use to get a subtotal.

Answer

Try this code $order_total = get_post_meta ($order_id , '_order_total', true);

Comments