SOLVED: Our Custom Post Type of 'Product' confuses & breaks Bricks (fatal error, thinks it's WooCommerce)

Bricks Version: 1.4.0.2
Browser: Chrome 103.0.5060.53 (Official Build) (x86_64)
OS: macOS/Win/Linux
URL: Private Build on DigitalOcean Server
Installed Plugins:

  • Advanced Scripts (2.3.4)
  • Fluent Forms Pro (4.3.8)
  • FluentSMTP (2.1.1)
  • HappyFiles Pro (1.7)
  • Meta Box (5.6.4)
  • Meta Box AIO (1.16.2)
  • SearchWP (4.2.3)
  • Two Factor (0.7.1)
  • WP Grid Builder (1.6.7)
  • WP Grid Builder - Map Facet (1.3.0)
  • WP Grid Builder - Meta Box (1.0.0)
    Environment:
    |Server info:|LiteSpeed||—|—|
    |MySQL version:|5.5.5-10.3.34-MariaDB-cll-lve|
    |PHP version:|7.4.30|
    |PHP post max size:|1024M|
    |PHP execution time limit:|1500|
    |PHP max input vars:|2000|
    |PHP safe mode:|-|
    |PHP memory limit:|1024M|
    |PHP max upload file size:|1024M|

Problem
We’ve created our own Custom Post Type through Meta Box called “products” (or “product” for singular). We are just making a product catalog not an e-commerce site so no WooCommerce will be installed. When we create a Bricks template (single) with conditions of show on: “Post type: (Product)” Bricks uses your /wp-content/themes/bricks/single-product.php which inside that on line 19 is looking for wc_print_notices( true ) which we believe is a WooCommerce function of which we do not have installed, which produces a fatal error and an entry in the error_log:

[25-Jun-2022 21:51:26 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function wc_print_notices() in /home/[USER]/[WEBSITE].com/wp-content/themes/bricks/single-product.php:19
Stack trace:
#0 /home/[USER]/[WEBSITE].com/wp-includes/template-loader.php(106): include()
#1 /home/[USER]/[WEBSITE].com/wp-blog-header.php(19): require_once('/home/[USER]/...')
#2 /home/[USER]/[WEBSITE].com/index.php(17): require('/home/[USER]/...')
#3 {main}
  thrown in /home/[USER]/[WEBSITE].com/wp-content/themes/bricks/single-product.php on line 19

It seems we are NOT allowed to make our own Custom Post Type of products(product) without breaking Bricks.

Our Short Term Solution
We’ve installed & activated the Bricks child theme and have copied the single-product.php into it, then changed its line 19 to:

 /* echo '<div class="woocommerce-notices-wrapper brx-container root">' . wc_print_notices( true ) . '</div>';  */

and the error is gone.

Our Request
Please can you make it so we can create our own ‘products(product)’ CPT without breaking Bricks or requiring WooCommerce?

We love your builder and this is our inaugural move away from Oxygen on production sites. We’d hate for this to hold us up or backstroke.

Thank you so much.

I’m here if you need me.
–Scott :grin::+1:

Hey Scott,
Thanks a lot for your report!

If you follow the official recommendations on creating a custom post type, especially when it comes to naming conventions, there shouldn’t be any issues.

Please take a look here and let me know if that fixes you issue:

Best regards,
timmse

2 Likes

Thank you.
We weighed that risk and it looks like this is a good example and deciding factor to privately namespace the ‘product’ CPT to something different like ‘brand_product’ and just use custom slug overrides.

Thank you. Will rename.

#SOLVED

–Scott