mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 10:55:00 +08:00
prevent shipping address change in paypal checkout
This commit is contained in:
parent
9dc95c0e28
commit
d0a4405d7e
2 changed files with 14 additions and 6 deletions
|
@ -154,6 +154,7 @@ class OrderEndpoint {
|
|||
* @param PaymentToken|null $payment_token The payment token.
|
||||
* @param PaymentMethod|null $payment_method The payment method.
|
||||
* @param string $paypal_request_id The paypal request id.
|
||||
* @param bool $shipping_address_is_fixed Whether the shipping address is changeable or not.
|
||||
*
|
||||
* @return Order
|
||||
* @throws RuntimeException If the request fails.
|
||||
|
@ -163,7 +164,8 @@ class OrderEndpoint {
|
|||
Payer $payer = null,
|
||||
PaymentToken $payment_token = null,
|
||||
PaymentMethod $payment_method = null,
|
||||
string $paypal_request_id = ''
|
||||
string $paypal_request_id = '',
|
||||
bool $shipping_address_is_fixed = false
|
||||
): Order {
|
||||
|
||||
$contains_physical_goods = false;
|
||||
|
@ -184,10 +186,13 @@ class OrderEndpoint {
|
|||
}
|
||||
);
|
||||
$shipping_preferences = $contains_physical_goods
|
||||
? ApplicationContext::SHIPPING_PREFERENCE_GET_FROM_FILE
|
||||
? $shipping_address_is_fixed ?
|
||||
ApplicationContext::SHIPPING_PREFERENCE_SET_PROVIDED_ADDRESS
|
||||
: ApplicationContext::SHIPPING_PREFERENCE_GET_FROM_FILE
|
||||
: ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING;
|
||||
$bearer = $this->bearer->bearer();
|
||||
$data = array(
|
||||
|
||||
$bearer = $this->bearer->bearer();
|
||||
$data = array(
|
||||
'intent' => $this->intent,
|
||||
'purchase_units' => array_map(
|
||||
static function ( PurchaseUnit $item ): array {
|
||||
|
|
|
@ -162,11 +162,14 @@ class CreateOrderEndpoint implements EndpointInterface {
|
|||
}
|
||||
|
||||
$this->set_bn_code( $data );
|
||||
$order = $this->api_endpoint->create(
|
||||
$shipping_address_is_fix = 'checkout' === $data['context'] ? true : false;
|
||||
$order = $this->api_endpoint->create(
|
||||
$purchase_units,
|
||||
$this->payer( $data, $wc_order ),
|
||||
null,
|
||||
$this->payment_method()
|
||||
$this->payment_method(),
|
||||
'',
|
||||
$shipping_address_is_fix
|
||||
);
|
||||
if ( 'checkout' === $data['context'] ) {
|
||||
$this->validate_checkout_form( $data['form'], $order );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue