15 1 0 4000 1 https://codeblock.co.za 300 true 0
theme-sticky-logo-alt

calculate_totals()

0 Comments

Framework / CMS

WooCommerce [Version: Since 2.2.0]

Syntax

Typical Usage

Calculate totals by looking at the contents of the WooCommerce order. Stores the totals and returns the order’s final total.

Accepted Parameters

  • with_taxes (boolean) (Optional) (Default = true): Whether or not to calculate taxes.

Return Value(s)

Returns a float value of the total cart value of the order.

Examples of calculate_totals()

Example 1

<?php
$user_id = get_current_user_id(); 
$args = array(
    'customer_id'   => $user_id
);

$new_order = wc_create_order($args);
$new_order->add_product( wc_get_product(1234), 4);
$new_order->calculate_totals();

Was This Helpful?

Previous Post
set_payment_method()
Next Post
update_status()

0 Comments

Leave a Reply