mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 13:44:42 +08:00
Ensure items contains tax
This commit is contained in:
parent
63d9f84ee3
commit
eb1fafbc61
1 changed files with 22 additions and 0 deletions
|
@ -111,6 +111,7 @@ class PayUponInvoiceOrderEndpoint {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$data = $this->ensure_tax( $data );
|
||||||
$data = $this->ensure_tax_rate( $data );
|
$data = $this->ensure_tax_rate( $data );
|
||||||
$data = $this->ensure_shipping( $data, $payment_source->to_array() );
|
$data = $this->ensure_shipping( $data, $payment_source->to_array() );
|
||||||
|
|
||||||
|
@ -196,6 +197,27 @@ class PayUponInvoiceOrderEndpoint {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensures items contains tax.
|
||||||
|
*
|
||||||
|
* @param array $data The data.
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function ensure_tax( array $data ): array {
|
||||||
|
$items_count = count( $data['purchase_units'][0]['items'] );
|
||||||
|
|
||||||
|
for ( $i = 0; $i < $items_count; $i++ ) {
|
||||||
|
if ( ! isset( $data['purchase_units'][0]['items'][ $i ]['tax'] ) ) {
|
||||||
|
$data['purchase_units'][0]['items'][ $i ]['tax'] = array(
|
||||||
|
'currency_code' => 'EUR',
|
||||||
|
'value' => '0.00',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures items contains tax rate.
|
* Ensures items contains tax rate.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue