Skip to content

Commit

Permalink
No longer load classic checkout scripts on the block checkout page
Browse files Browse the repository at this point in the history
  • Loading branch information
james-allan committed Jan 23, 2024
1 parent 24c9fab commit 514c25b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 10 additions & 1 deletion includes/class-wc-stripe-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,16 @@ public static function convert_wc_locale_to_stripe_locale( $wc_locale ) {
* @return boolean
*/
public static function has_cart_or_checkout_on_current_page() {
return is_cart() || is_checkout() || has_block( 'woocommerce/cart' ) || has_block( 'woocommerce/checkout' );
return is_cart() || is_checkout() || self::has_cart_or_checkout_block_on_current_page();
}

/**
* Checks if this page has a cart or checkout block.
*
* @return bool
*/
public static function has_cart_or_checkout_block_on_current_page() {
return has_block( 'woocommerce/cart' ) || has_block( 'woocommerce/checkout' );
}

/**
Expand Down
11 changes: 8 additions & 3 deletions includes/payment-methods/class-wc-stripe-upe-payment-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,14 @@ public function payment_scripts() {
true
);

wp_register_style( 'stripelink_styles', plugins_url( 'assets/css/stripe-link.css', WC_STRIPE_MAIN_FILE ), [], WC_STRIPE_VERSION );
wp_enqueue_style( 'stripelink_styles' );

// The rest of this function is specific to classic pages so bail if we're not on one.
if ( WC_Stripe_Helper::has_cart_or_checkout_block_on_current_page() ) {
return;
}

wp_register_script(
'wc-stripe-upe-classic',
WC_STRIPE_PLUGIN_URL . '/build/upe_classic.js',
Expand Down Expand Up @@ -284,9 +292,6 @@ public function payment_scripts() {

wp_enqueue_script( 'wc-stripe-upe-classic' );
wp_enqueue_style( 'wc-stripe-upe-classic' );

wp_register_style( 'stripelink_styles', plugins_url( 'assets/css/stripe-link.css', WC_STRIPE_MAIN_FILE ), [], WC_STRIPE_VERSION );
wp_enqueue_style( 'stripelink_styles' );
}

/**
Expand Down

0 comments on commit 514c25b

Please sign in to comment.