Merge pull request #1786 from woocommerce/PCP-2139-release-2-4-0-rc-1-place-order-button-remains-could-not-retrieve-order

release 2.4.0_rc1 Place order button remains - Could not retrieve order (2139)
This commit is contained in:
Emili Castells 2023-10-20 16:53:32 +02:00 committed by GitHub
commit 9d43e736c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 63 additions and 19 deletions

View file

@ -11,6 +11,7 @@ namespace WooCommerce\PayPalCommerce\Googlepay;
use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry;
use WooCommerce\PayPalCommerce\Button\Assets\ButtonInterface;
use WooCommerce\PayPalCommerce\Button\Assets\SmartButtonInterface;
use WooCommerce\PayPalCommerce\Googlepay\Endpoint\UpdatePaymentDataEndpoint;
use WooCommerce\PayPalCommerce\Googlepay\Helper\ApmProductStatus;
use WooCommerce\PayPalCommerce\Googlepay\Helper\AvailabilityNotice;
@ -85,7 +86,20 @@ class GooglepayModule implements ModuleInterface {
add_action(
'wp_enqueue_scripts',
static function () use ( $c, $button ) {
$button->enqueue();
$smart_button = $c->get( 'button.smart-button' );
assert( $smart_button instanceof SmartButtonInterface );
if ( $smart_button->should_load_ppcp_script() ) {
$button->enqueue();
}
if ( has_block( 'woocommerce/checkout' ) || has_block( 'woocommerce/cart' ) ) {
/**
* Should add this to the ButtonInterface.
*
* @psalm-suppress UndefinedInterfaceMethod
*/
$button->enqueue_styles();
}
}
);