NO BUG: Fatal Error - operator not supported for strings woocommerce.php:2352

Bricks Version : 1.9.9
Browser : Opera
OS : Win.
URL : n/a

Uncaught Error: operator not supported for strings in \bricks\includes\woocommerce.php:2352
Reference: $attributes[‘class’] = ‘woocommerce’;

/**
		 * Add .woocommerce class to the main tag (#brx-content) when previewing woo templates in frontend OR if the current page is my account page
		 *
		 * Otherwise not all Woo CSS & JS is applied. In builder, we add this class inside TheDynamicArea.vue
		 *
		 * Woo Phase 3
		 */
		public function template_preview_main_classes( $attributes ) {
			$post_id         = get_the_ID();
			$is_account_page = is_account_page();

			if ( ! Helpers::is_bricks_template( $post_id ) && ! $is_account_page ) {
				return $attributes;
			}

			$template_type = Templates::get_template_type( get_the_ID() );

			if ( strpos( $template_type, 'wc_' ) === false && ! $is_account_page ) {
				return $attributes;
			}
			
			// NOTE: Adds 20px padding to .woocommerce-cart .woocommerce (on tablet portrait), when previewing the template in frontend.
			$attributes['class'][] = 'woocommerce';

			return $attributes;
		}

Temp fix

			
			// Ensure $attributes['class'] is an array
			if (!isset($attributes['class']) || !is_array($attributes['class'])) {
				$attributes['class'] = isset($attributes['class']) ? [$attributes['class']] : [];
			}

Hi @mizzinc ,

Thank you so much for reporting the issue.

Please may I know if you have any plugins or custom code that triggered this fatal error?

The $attributes supposed to be an array.

Regards,
Jenn

1 Like

Hi @itchycode

Thanks for the nudge and apologies for not carrying out a full debug process.
Confirming this was a result of a custom code applied to

add_filter( 'bricks/content/attributes'

No bug.