WC_Payment_Gateway::get_order_total
Get the order total in checkout and pay_for_order.
Method of the class: WC_Payment_Gateway{}
No Hooks.
Returns
float.
Usage
// protected - for code of main (parent) or child class $result = $this->get_order_total();
WC_Payment_Gateway::get_order_total() WC Payment Gateway::get order total code WC 10.8.1
protected function get_order_total() {
$total = 0;
$order_id = absint( get_query_var( 'order-pay' ) );
// Gets order total from "pay for order" page.
if ( 0 < $order_id ) {
$order = wc_get_order( $order_id );
if ( $order ) {
$total = (float) $order->get_total();
}
// Gets order total from cart/checkout.
} elseif ( 0 < WC()->cart->total ) {
$total = (float) WC()->cart->total;
}
return $total;
}