From b858d545d6d6c167fca0d468d228c5d356068603 Mon Sep 17 00:00:00 2001 From: Darren Ethier Date: Fri, 9 Jun 2023 14:33:43 -0400 Subject: [PATCH 1/3] Replace mini cart widget with mini-cart block --- header.php | 7 +++++ ...refront-woocommerce-template-functions.php | 28 +++++++++++++------ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/header.php b/header.php index 6547d1d10..087448833 100644 --- a/header.php +++ b/header.php @@ -15,6 +15,13 @@ +' ) : null; +?> + diff --git a/inc/woocommerce/storefront-woocommerce-template-functions.php b/inc/woocommerce/storefront-woocommerce-template-functions.php index 8630aa2c6..e03ada7ac 100644 --- a/inc/woocommerce/storefront-woocommerce-template-functions.php +++ b/inc/woocommerce/storefront-woocommerce-template-functions.php @@ -115,6 +115,11 @@ function storefront_product_search() { } } +function storefront_get_block_mini_cart() { + global $storefront_block_mini_cart; + return $storefront_block_mini_cart ?? ''; +} + if ( ! function_exists( 'storefront_header_cart' ) ) { /** * Display Header Cart @@ -124,6 +129,7 @@ function storefront_product_search() { * @return void */ function storefront_header_cart() { + $block_mini_cart = storefront_get_block_mini_cart(); if ( storefront_is_woocommerce_activated() ) { if ( is_cart() ) { $class = 'current-menu-item'; @@ -131,14 +137,20 @@ function storefront_header_cart() { $class = ''; } ?> - + Date: Fri, 9 Jun 2023 14:33:52 -0400 Subject: [PATCH 2/3] Add theme support for template parts. --- inc/class-storefront.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/inc/class-storefront.php b/inc/class-storefront.php index 31bd5a127..53b5ee067 100644 --- a/inc/class-storefront.php +++ b/inc/class-storefront.php @@ -247,6 +247,13 @@ public function setup() { ), ) ); + + /** + * Add support for block emplate parts. + * + * @return void + */ + add_theme_support('block-template-parts'); } /** From dd02088c4f3661e157de7fdc55bb2f34f397f887 Mon Sep 17 00:00:00 2001 From: Darren Ethier Date: Fri, 9 Jun 2023 17:50:08 -0400 Subject: [PATCH 3/3] fix phpcs linting errors --- inc/class-storefront.php | 2 +- .../storefront-woocommerce-template-functions.php | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/inc/class-storefront.php b/inc/class-storefront.php index 53b5ee067..6202b2b92 100644 --- a/inc/class-storefront.php +++ b/inc/class-storefront.php @@ -253,7 +253,7 @@ public function setup() { * * @return void */ - add_theme_support('block-template-parts'); + add_theme_support( 'block-template-parts' ); } /** diff --git a/inc/woocommerce/storefront-woocommerce-template-functions.php b/inc/woocommerce/storefront-woocommerce-template-functions.php index e03ada7ac..74a879a5c 100644 --- a/inc/woocommerce/storefront-woocommerce-template-functions.php +++ b/inc/woocommerce/storefront-woocommerce-template-functions.php @@ -115,6 +115,11 @@ function storefront_product_search() { } } +/** + * Returns the output for the mini-cart block. + * + * @return string + */ function storefront_get_block_mini_cart() { global $storefront_block_mini_cart; return $storefront_block_mini_cart ?? ''; @@ -143,10 +148,11 @@ function storefront_header_cart() { -->