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

Commit

Permalink
Enable new notice styles
Browse files Browse the repository at this point in the history
  • Loading branch information
nielslange committed Dec 5, 2023
1 parent d51816f commit 15baad7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
1 change: 1 addition & 0 deletions assets/js/base/components/notice-banner/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
background-color: $gray-800;
flex-shrink: 0;
flex-grow: 0;
height: 100%;
}

> .wc-block-components-button {
Expand Down
28 changes: 13 additions & 15 deletions src/Domain/Services/Notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,12 @@ public function __construct( Package $package ) {
}

/**
* Set all hooks related to adding Checkout Draft order functionality to Woo Core. This is only enabled if the user
* is using the new block based cart/checkout.
* Initialize notice hooks.
*/
public function init() {
if ( CartCheckoutUtils::is_cart_block_default() || CartCheckoutUtils::is_checkout_block_default() ) {
add_filter( 'woocommerce_kses_notice_allowed_tags', [ $this, 'add_kses_notice_allowed_tags' ] );
add_filter( 'wc_get_template', [ $this, 'get_notices_template' ], 10, 5 );
add_action(
'wp_head',
function() {
// These pages may return notices in ajax responses, so we need the styles to be ready.
if ( is_cart() || is_checkout() ) {
wp_enqueue_style( 'wc-blocks-style' );
}
}
);
}
add_filter( 'woocommerce_kses_notice_allowed_tags', [ $this, 'add_kses_notice_allowed_tags' ] );
add_filter( 'wc_get_template', [ $this, 'get_notices_template' ], 10, 5 );
add_action( 'wp_head', [ $this, 'enqueue_notice_styles' ] );
}

/**
Expand Down Expand Up @@ -101,4 +90,13 @@ public function get_notices_template( $template, $template_name, $args, $templat
}
return $template;
}

/**
* Replaces all notices with the new block based notices.
*
* @return void
*/
public function enqueue_notice_styles() {
wp_enqueue_style( 'wc-blocks-style' );
}
}

0 comments on commit 15baad7

Please sign in to comment.