mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Add some validations to GooglePay scripts
This commit is contained in:
parent
5d406ea612
commit
567a7a2065
3 changed files with 11 additions and 2 deletions
|
@ -422,7 +422,7 @@ class ApplePayButton implements ButtonInterface {
|
|||
}
|
||||
$applepay_request_data_object->order_data( $context );
|
||||
$this->update_posted_data( $applepay_request_data_object );
|
||||
if ( $context == 'product' ) {
|
||||
if ( $context === 'product' ) {
|
||||
$cart_item_key = $this->prepare_cart( $applepay_request_data_object );
|
||||
$cart = WC()->cart;
|
||||
$address = $applepay_request_data_object->shipping_address();
|
||||
|
|
|
@ -16,7 +16,9 @@ import GooglepayManager from "./GooglepayManager";
|
|||
};
|
||||
|
||||
jQuery(document.body).on('updated_cart_totals updated_checkout', () => {
|
||||
manager.reinit();
|
||||
if (manager) {
|
||||
manager.reinit();
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener(
|
||||
|
|
|
@ -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;
|
||||
|
@ -86,6 +87,12 @@ class GooglepayModule implements ModuleInterface {
|
|||
add_action(
|
||||
'wp_enqueue_scripts',
|
||||
static function () use ( $c, $button ) {
|
||||
$smart_button = $c->get( 'button.smart-button' );
|
||||
assert( $smart_button instanceof SmartButtonInterface );
|
||||
$page_has_block = has_block( 'woocommerce/checkout' ) || has_block( 'woocommerce/cart' );
|
||||
if ( ! $smart_button->should_load_ppcp_script() && ! $page_has_block ) {
|
||||
return;
|
||||
}
|
||||
$button->enqueue();
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue