WC_Gateway_Paypal_Request::get_paypal_order_purchase_unit_amountpublicWC 1.0

Get the amount data for the PayPal order purchase unit field.

Method of the class: WC_Gateway_Paypal_Request{}

No Hooks.

Returns

Array.

Usage

$WC_Gateway_Paypal_Request = new WC_Gateway_Paypal_Request();
$WC_Gateway_Paypal_Request->get_paypal_order_purchase_unit_amount( $order );
$order(WC_Order) (required)
Order object.

WC_Gateway_Paypal_Request::get_paypal_order_purchase_unit_amount() code WC 10.4.3

public function get_paypal_order_purchase_unit_amount( $order ) {
	$currency = $order->get_currency();

	return array(
		'currency_code' => $currency,
		'value'         => wc_format_decimal( $order->get_total(), wc_get_price_decimals() ),
		'breakdown'     => array(
			'item_total' => array(
				'currency_code' => $currency,
				'value'         => wc_format_decimal( $this->get_paypal_order_items_subtotal( $order ), wc_get_price_decimals() ),
			),
			'shipping'   => array(
				'currency_code' => $currency,
				'value'         => wc_format_decimal( $order->get_shipping_total(), wc_get_price_decimals() ),
			),
			'tax_total'  => array(
				'currency_code' => $currency,
				'value'         => wc_format_decimal( $order->get_total_tax(), wc_get_price_decimals() ),
			),
			'discount'   => array(
				'currency_code' => $currency,
				'value'         => wc_format_decimal( $order->get_discount_total(), wc_get_price_decimals() ),
			),
		),
	);
}