Merge branch 'trunk' into PCP-1389-pay-later-button-and-message-get-hidden-when-product-cart-checkout-value-is-outside-of-range

This commit is contained in:
Pedro Silva 2023-07-17 11:19:55 +01:00 committed by GitHub
commit cc97f84acb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 630 additions and 9 deletions

View file

@ -258,6 +258,12 @@ class CreateOrderEndpoint implements EndpointInterface {
} else {
$this->purchase_unit = $this->purchase_unit_factory->from_wc_cart( null, $this->handle_shipping_in_paypal );
// Do not allow completion by webhooks when started via non-checkout buttons,
// it is needed only for some APMs in checkout.
if ( in_array( $data['context'], array( 'product', 'cart', 'cart-block' ), true ) ) {
$this->purchase_unit->set_custom_id( '' );
}
// The cart does not have any info about payment method, so we must handle free trial here.
if ( (
in_array( $payment_method, array( CreditCardGateway::ID, CardButtonGateway::ID ), true )