Show shipping methods in paypal if express without review

This commit is contained in:
Alex P 2023-04-25 15:06:24 +03:00
parent 8efa0e6da3
commit 9d638a57e3
No known key found for this signature in database
GPG key ID: 54487A734A204D71
12 changed files with 355 additions and 16 deletions

View file

@ -145,6 +145,13 @@ class CreateOrderEndpoint implements EndpointInterface {
*/
private $pay_now_contexts;
/**
* If true, the shipping methods are sent to PayPal allowing the customer to select it inside the popup.
*
* @var bool
*/
private $handle_shipping_in_paypal;
/**
* The logger.
*
@ -167,6 +174,7 @@ class CreateOrderEndpoint implements EndpointInterface {
* @param string $card_billing_data_mode The value of card_billing_data_mode from the settings.
* @param bool $early_validation_enabled Whether to execute WC validation of the checkout form.
* @param string[] $pay_now_contexts The contexts that should have the Pay Now button.
* @param bool $handle_shipping_in_paypal If true, the shipping methods are sent to PayPal allowing the customer to select it inside the popup.
* @param LoggerInterface $logger The logger.
*/
public function __construct(
@ -182,6 +190,7 @@ class CreateOrderEndpoint implements EndpointInterface {
string $card_billing_data_mode,
bool $early_validation_enabled,
array $pay_now_contexts,
bool $handle_shipping_in_paypal,
LoggerInterface $logger
) {
@ -197,6 +206,7 @@ class CreateOrderEndpoint implements EndpointInterface {
$this->card_billing_data_mode = $card_billing_data_mode;
$this->early_validation_enabled = $early_validation_enabled;
$this->pay_now_contexts = $pay_now_contexts;
$this->handle_shipping_in_paypal = $handle_shipping_in_paypal;
$this->logger = $logger;
}
@ -236,7 +246,7 @@ class CreateOrderEndpoint implements EndpointInterface {
}
$this->purchase_unit = $this->purchase_unit_factory->from_wc_order( $wc_order );
} else {
$this->purchase_unit = $this->purchase_unit_factory->from_wc_cart();
$this->purchase_unit = $this->purchase_unit_factory->from_wc_cart( null, $this->handle_shipping_in_paypal );
// The cart does not have any info about payment method, so we must handle free trial here.
if ( (