Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit a488672

Browse files
authored
Preparation for including Blocks as the default checkout experience in WC 8.3 (#11372)
1 parent 0180afb commit a488672

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/Installer.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,23 @@ public function install() {
2424
}
2525

2626
/**
27-
* Modifies default page content.
27+
* Modifies default page content replacing it with classic shortcode block.
28+
* We check for shortcode as default because after WooCommerce 8.3, block based checkout is used by default.
29+
* This only runs on Tools > Create Pages as the filter is not applied on WooCommerce plugin activation.
2830
*
2931
* @param array $pages Default pages.
3032
* @return array
3133
*/
3234
public function create_pages( $pages ) {
33-
$pages['cart']['content'] = '<!-- wp:woocommerce/classic-shortcode {"shortcode":"cart"} /-->';
34-
$pages['checkout']['content'] = '<!-- wp:woocommerce/classic-shortcode {"shortcode":"checkout"} /-->';
35+
36+
if ( '<!-- wp:shortcode -->[woocommerce_cart]<!-- /wp:shortcode -->' === $pages['cart']['content'] ) {
37+
$pages['cart']['content'] = '<!-- wp:woocommerce/classic-shortcode {"shortcode":"cart"} /-->';
38+
}
39+
40+
if ( '<!-- wp:shortcode -->[woocommerce_checkout]<!-- /wp:shortcode -->' === $pages['checkout']['content'] ) {
41+
$pages['checkout']['content'] = '<!-- wp:woocommerce/classic-shortcode {"shortcode":"checkout"} /-->';
42+
}
43+
3544
return $pages;
3645
}
3746

0 commit comments

Comments
 (0)