: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* WooCommerce Modules: ET_Builder_Module_Woocommerce_Cart_Notice class
* The ET_Builder_Module_Woocommerce_Cart_Notice Class is responsible for rendering the
* Cart Notice markup using the WooCommerce template.
* Class representing WooCommerce Cart Notice component.
class ET_Builder_Module_Woocommerce_Cart_Notice extends ET_Builder_Module {
$this->name = esc_html__( 'Woo Cart Notice', 'et_builder' );
$this->plural = esc_html__( 'Woo Cart Notices', 'et_builder' );
$this->slug = 'et_pb_wc_cart_notice';
$this->vb_support = 'on';
$this->settings_modal_toggles = array(
'main_content' => et_builder_i18n( 'Content' ),
'title' => et_builder_i18n( 'Text' ),
$this->main_css_element = '%%order_class%% .woocommerce-message';
$this->advanced_fields = array(
'label' => et_builder_i18n( 'Text' ),
'main' => '%%order_class%% .woocommerce-message',
// CPT style uses `!important` so outputting important is inevitable.
'hide_text_align' => true,
'module_alignment' => '%%order_class%%.et_pb_module',
'margin_padding' => array(
'padding' => '%%order_class%% .woocommerce-message',
'custom_padding' => array(
'default' => '15px|15px|15px|15px|false|false',
'custom_margin' => array(
'default' => '0em|0em|2em|0em|false|false',
'label' => et_builder_i18n( 'Button' ),
'main' => '%%order_class%% .wc-forward',
'use_alignment' => false,
'main' => '%%order_class%% .wc-forward',
'margin_padding' => array(
'use_background_layout' => true,
'main' => '%%order_class%%',
'text_shadow' => '%%order_class%%',
'text_orientation' => array(
'background_layout' => array(
// Don't add text-shadow fields since they already are via font-options.
// Defined explicitly to solve
// @see https://github.com/elegantthemes/Divi/issues/17200#issuecomment-542140907
'main' => '%%order_class%% .woocommerce-message',
// Important is required to override
// Appearance ⟶ Customize ⟶ Color schemes styles.
$this->custom_css_fields = array(
'label' => et_builder_i18n( 'Text' ),
'selector' => '.woocommerce-message',
'label' => et_builder_i18n( 'Button' ),
'selector' => '.wc-forward',
$this->help_videos = array(
'name' => esc_html__( 'Divi WooCommerce Modules', 'et_builder' ),
* Disable default cart notice if needed. Priority need to be set at 100 to
* that the callback is being called after modules are being loaded.
* See: et_builder_load_framework()
'ET_Builder_Module_Woocommerce_Cart_Notice',
'disable_default_notice',
// Clear notices array which was modified during render.
add_action( 'wp_footer', array( 'ET_Builder_Module_Woocommerce_Cart_Notice', 'clear_notices' ) );
public function get_fields() {
'product' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
'default' => ET_Builder_Module_Helper_Woocommerce_Modules::get_product_default(),
'computed_affects' => array(
'product_filter' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
'computed_affects' => array(
'__cart_notice' => array(
'computed_callback' => array(
'ET_Builder_Module_Woocommerce_Cart_Notice',
'computed_depends_on' => array(
'computed_minumum' => array(
* Disable default WooCommerce notice if current page's main query post content contains
* Cart Notice module to prevent duplicate cart notices being rendered AND to make Cart Notice
* module can render the notices correctly (notices are cleared once they are rendered)
public static function disable_default_notice() {
$remove_default_notices = false;
$tb_layouts = et_theme_builder_get_template_layouts();
$tb_layout_types = et_theme_builder_get_layout_post_types();
// Check if a TB layout outputs the notices.
foreach ( $tb_layout_types as $post_type ) {
$id = et_()->array_get( $tb_layouts, array( $post_type, 'id' ), 0 );
$enabled = et_()->array_get( $tb_layouts, array( $post_type, 'enabled' ), 0 );
if ( ! $id || ! $enabled ) {
$content = get_post_field( 'post_content', $id );
if ( has_shortcode( $content, 'et_pb_wc_cart_notice' ) ) {
$remove_default_notices = true;
// Check if the product itself outputs the notices.
if ( isset( $post->post_content ) && has_shortcode( $post->post_content, 'et_pb_wc_cart_notice' ) ) {
$remove_default_notices = true;
if ( $remove_default_notices ) {
remove_action( 'woocommerce_before_single_product', 'woocommerce_output_all_notices', 10 );
* We update Woo Notices array during modules render and need to cleat it
* after Woo Product is fully rendered to avoid duplicated notifications on
public static function clear_notices() {
if ( ! empty( WC()->session ) ) {
WC()->session->set( 'wc_notices', null );
* Gets the Cart notice markup.
* @param array $args Additional arguments.
public static function get_cart_notice( $args = array() ) {
if ( et_fb_enabled() || et_fb_is_builder_ajax() || et_fb_is_computed_callback_ajax() ) {
return et_builder_wc_render_module_template( 'wc_print_notice', $args );
return et_builder_wc_render_module_template( 'wc_print_notices', $args );
function get_button_classname() {
* Renders the module output.
* @param array $attrs List of attributes.
* @param string $content Content being processed.
* @param string $render_slug Slug of module that is used for rendering output.
public function render( $attrs, $content = null, $render_slug ) {
* In front end, do not print cart notice module if there is no notices exist.
* There is no custom style rendered below (to make sure that styles are correctly cached
* nevertheless), thus it is fine to exit early;
if ( ! empty( WC()->session ) && empty( WC()->session->get( 'wc_notices', array() ) ) ) {
ET_Builder_Module_Helper_Woocommerce_Modules::process_background_layout_data( $render_slug, $this );
ET_Builder_Module_Helper_Woocommerce_Modules::process_custom_button_icons( $render_slug, $this );
$this->add_classname( $this->get_text_orientation_classname() );
$output = self::get_cart_notice( $this->props );
return $this->_render_module_wrapper( $output, $render_slug );
new ET_Builder_Module_Woocommerce_Cart_Notice();