mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 10:55:00 +08:00
Merge pull request #2234 from woocommerce/PCP-3129-fastlane-and-acceptance-criteria-given-visible-at-the-same-time-for-guest-user
AXO: Fix the Classic Checkout and Cart shortcode check (3129)
This commit is contained in:
commit
007b2d6a94
1 changed files with 21 additions and 2 deletions
|
@ -114,7 +114,7 @@ class CartCheckoutDetector {
|
|||
*/
|
||||
public static function has_classic_checkout(): bool {
|
||||
$checkout_page_id = wc_get_page_id( 'checkout' );
|
||||
return $checkout_page_id && has_block( 'woocommerce/classic-shortcode', $checkout_page_id );
|
||||
return $checkout_page_id && ( has_block( 'woocommerce/classic-shortcode', $checkout_page_id ) || self::has_classic_shortcode( $checkout_page_id, 'woocommerce_checkout' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -124,6 +124,25 @@ class CartCheckoutDetector {
|
|||
*/
|
||||
public static function has_classic_cart(): bool {
|
||||
$cart_page_id = wc_get_page_id( 'cart' );
|
||||
return $cart_page_id && has_block( 'woocommerce/classic-shortcode', $cart_page_id );
|
||||
return $cart_page_id && ( has_block( 'woocommerce/classic-shortcode', $cart_page_id ) || self::has_classic_shortcode( $cart_page_id, 'woocommerce_cart' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a page has a specific shortcode.
|
||||
*
|
||||
* @param int $page_id The ID of the page.
|
||||
* @param string $shortcode The shortcode to check for.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private static function has_classic_shortcode( int $page_id, string $shortcode ): bool {
|
||||
if ( ! $page_id ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$page = get_post( $page_id );
|
||||
$page_content = is_object( $page ) ? $page->post_content : '';
|
||||
|
||||
return str_contains( $page_content, $shortcode );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue