mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +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 PaymentToken|null $payment_token The payment token.
|
||||||
* @param PaymentMethod|null $payment_method The payment method.
|
* @param PaymentMethod|null $payment_method The payment method.
|
||||||
* @param string $paypal_request_id The paypal request id.
|
* @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
|
* @return Order
|
||||||
* @throws RuntimeException If the request fails.
|
* @throws RuntimeException If the request fails.
|
||||||
|
@ -163,7 +164,8 @@ class OrderEndpoint {
|
||||||
Payer $payer = null,
|
Payer $payer = null,
|
||||||
PaymentToken $payment_token = null,
|
PaymentToken $payment_token = null,
|
||||||
PaymentMethod $payment_method = null,
|
PaymentMethod $payment_method = null,
|
||||||
string $paypal_request_id = ''
|
string $paypal_request_id = '',
|
||||||
|
bool $shipping_address_is_fixed = false
|
||||||
): Order {
|
): Order {
|
||||||
|
|
||||||
$contains_physical_goods = false;
|
$contains_physical_goods = false;
|
||||||
|
@ -184,8 +186,11 @@ class OrderEndpoint {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
$shipping_preferences = $contains_physical_goods
|
$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;
|
: ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING;
|
||||||
|
|
||||||
$bearer = $this->bearer->bearer();
|
$bearer = $this->bearer->bearer();
|
||||||
$data = array(
|
$data = array(
|
||||||
'intent' => $this->intent,
|
'intent' => $this->intent,
|
||||||
|
|
|
@ -162,11 +162,14 @@ class CreateOrderEndpoint implements EndpointInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->set_bn_code( $data );
|
$this->set_bn_code( $data );
|
||||||
|
$shipping_address_is_fix = 'checkout' === $data['context'] ? true : false;
|
||||||
$order = $this->api_endpoint->create(
|
$order = $this->api_endpoint->create(
|
||||||
$purchase_units,
|
$purchase_units,
|
||||||
$this->payer( $data, $wc_order ),
|
$this->payer( $data, $wc_order ),
|
||||||
null,
|
null,
|
||||||
$this->payment_method()
|
$this->payment_method(),
|
||||||
|
'',
|
||||||
|
$shipping_address_is_fix
|
||||||
);
|
);
|
||||||
if ( 'checkout' === $data['context'] ) {
|
if ( 'checkout' === $data['context'] ) {
|
||||||
$this->validate_checkout_form( $data['form'], $order );
|
$this->validate_checkout_form( $data['form'], $order );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue