Automattic\WooCommerce\Gateways\PayPal
Request::get_paypal_order_purchase_unit_amount
Get the amount data for the PayPal order purchase unit field.
Method of the class: Request{}
No Hooks.
Returns
Array.
Usage
$Request = new Request(); $Request->get_paypal_order_purchase_unit_amount( ?WC_Order $order ): array;
- ?WC_Order $order(required)
- .
Request::get_paypal_order_purchase_unit_amount() Request::get paypal order purchase unit amount code WC 10.7.0
public function get_paypal_order_purchase_unit_amount( ?WC_Order $order ): array {
if ( ! $order ) {
return array();
}
$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() ),
),
),
);
}