mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 16:24:33 +08:00
Change shipping preference if purchase units does not contain shipping
This commit is contained in:
parent
79e2dd2ef5
commit
3295488b29
1 changed files with 20 additions and 0 deletions
|
@ -193,6 +193,10 @@ class OrderEndpoint {
|
||||||
: ApplicationContext::SHIPPING_PREFERENCE_GET_FROM_FILE
|
: ApplicationContext::SHIPPING_PREFERENCE_GET_FROM_FILE
|
||||||
: ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING;
|
: ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING;
|
||||||
|
|
||||||
|
if ( $this->items_without_shipping( $items ) ) {
|
||||||
|
$shipping_preferences = ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING;
|
||||||
|
}
|
||||||
|
|
||||||
$bearer = $this->bearer->bearer();
|
$bearer = $this->bearer->bearer();
|
||||||
$data = array(
|
$data = array(
|
||||||
'intent' => $this->intent,
|
'intent' => $this->intent,
|
||||||
|
@ -572,4 +576,20 @@ class OrderEndpoint {
|
||||||
$new_order = $this->order( $order_to_update->id() );
|
$new_order = $this->order( $order_to_update->id() );
|
||||||
return $new_order;
|
return $new_order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if items contains shipping.
|
||||||
|
*
|
||||||
|
* @param array $items The items.
|
||||||
|
* @return bool Whether items contains shipping or not.
|
||||||
|
*/
|
||||||
|
private function items_without_shipping( array $items ): bool {
|
||||||
|
foreach ( $items as $item ) {
|
||||||
|
if ( ! $item->shipping() ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue