Skip to content

Commit

Permalink
fix(ras-acc): correct checks when rendering modal checkout template (#…
Browse files Browse the repository at this point in the history
…1902)

This fixes two small checks when rendering the modal checkout template:

- Checks for cart and checkout pages in addition to wc endpoints
- Checks for the existence of `notice` key before using
  • Loading branch information
chickenn00dle authored Oct 11, 2024
1 parent 96bac00 commit dd46fcb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions includes/class-modal-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,12 @@ public static function get_checkout_template( $template ) {
if ( ! self::is_modal_checkout() ) {
return $template;
}
// Ensure we are on a wc endpoint.
if ( ! function_exists( 'is_wc_endpoint_url' ) && ! is_wc_endpoint_url() ) {
// Ensure we are on a wc page or endpoint.
if (
( ! function_exists( 'is_checkout' ) && ! is_checkout() ) &&
( ! function_exists( 'is_cart' ) && ! is_cart() ) &&
( ! function_exists( 'is_wc_endpoint_url' ) && ! is_wc_endpoint_url() )
) {
return $template;
}
$class_prefix = self::get_class_prefix();
Expand Down Expand Up @@ -711,7 +715,7 @@ public static function get_checkout_template( $template ) {
$message = __( "We're sorry, there was an unexpected error. Please try again in a few minutes.", 'newspack-blocks' );
if ( ! empty( $wc_errors ) ) {
$error = $wc_errors[0];
if ( is_array( $error ) ) {
if ( is_array( $error ) && isset( $error['notice'] ) ) {
$message = $error['notice'];
}
}
Expand Down

0 comments on commit dd46fcb

Please sign in to comment.