Block Rendering Issues
Symptoms
Section titled “Symptoms”- Commerce blocks not appearing in editor
- Blocks render as empty on frontend
- “This block contains unexpected or invalid content” error
- Block styling broken or missing
- Product data not loading in blocks
Common Causes
Section titled “Common Causes”1. Parent Block Requirements
Section titled “1. Parent Block Requirements”- Child blocks placed without required parent
- Incorrect block nesting hierarchy
- Parent block context not available
2. Missing BigCommerce Data
Section titled “2. Missing BigCommerce Data”- Product not synced to WordPress®
- Product variant/option data incomplete
- GraphQL query returning empty results
3. Build/Asset Issues
Section titled “3. Build/Asset Issues”- Block JavaScript not loading
- CSS files missing or not enqueued
- Commons chunk dependency missing
block.jsonfile not found
4. Theme Compatibility
Section titled “4. Theme Compatibility”- Theme blocking editor styles
- CSS conflicts with theme styles
- Theme not loading block assets
- Font family or color variables not available
Solutions
Section titled “Solutions”Fix Parent-Child Block Errors
Section titled “Fix Parent-Child Block Errors”Some blocks require specific parent blocks to function:
Example: Product variants must be inside Product Details
Section titled “Example: Product variants must be inside Product Details”❌ Wrong:
- Product Variants block (standalone)✅ Correct:
- Product Details block - Product Variants block (child)To fix in editor:
- Remove the standalone child block
- Add the parent block (e.g., Product Details)
- The child block should auto-populate inside parent
- If not, manually add the child block inside parent
Verify Product Data Sync
Section titled “Verify Product Data Sync”If blocks render but show no products:
-
Check product sync status:
Terminal window wp post list --post_type=bigcommerce_product --posts_per_page=5 -
Verify products exist in WordPress® database
-
Force resync if products missing:
- Go to Commerce Connect → Settings → Advanced
- Click “Sync Products Now”
-
Check specific product has required data:
Terminal window wp post get 123 --format=json
Fix Missing Block Assets
Section titled “Fix Missing Block Assets”If blocks don’t appear in editor or show as broken:
-
Verify build directory exists:
Terminal window ls -la wp-content/plugins/commerce-connect/build/ -
Check for
block.jsonfiles:Terminal window find wp-content/plugins/commerce-connect/build/ -name "block.json" -
Rebuild assets if missing:
Terminal window cd wp-content/plugins/commerce-connectnpm installnpm run build -
Clear WordPress® cache:
Terminal window wp cache flush
Fix Commons Chunk Dependency
Section titled “Fix Commons Chunk Dependency”All blocks depend on the commerce-connect-commons.js shared chunk:
-
Verify commons script registered:
Terminal window wp eval 'wp_scripts(); print_r(wp_scripts()->registered["commerce-connect-commons"]);' -
Check commons asset file exists:
Terminal window ls -la wp-content/plugins/commerce-connect/build/commerce-connect-commons.asset.php -
If missing, rebuild:
Terminal window npm run build
Fix Theme Style Conflicts
Section titled “Fix Theme Style Conflicts”If blocks display but styling is broken:
-
Check editor styles loaded:
- Open block editor
- Inspect element with DevTools
- Look for
ecom-ui-styles.cssin Network tab
-
Verify CSS variables available:
// In browser consolegetComputedStyle(document.documentElement).getPropertyValue('--ecom-ui-primary-button-color-background'); -
If empty, check theme.json has color/typography settings:
{"settings": {"color": {"palette": [...]},"typography": {"fontFamilies": [...]}}} -
Regenerate CSS variables:
- Go to Commerce Connect → Settings → Design
- Click “Reset to Theme Defaults”
- Save settings to regenerate inline styles
Fix Block Category Not Showing
Section titled “Fix Block Category Not Showing”If Commerce Connect blocks don’t appear in editor:
-
Verify block category registered:
Terminal window wp eval '$categories = get_default_block_categories();foreach($categories as $cat) {if($cat["slug"] === "commerce-connect") {print_r($cat);}}' -
Check for JavaScript errors in browser console
-
Try refreshing editor or clearing browser cache
Debug Block Render Issues
Section titled “Debug Block Render Issues”For blocks that render empty or show errors:
-
Enable WordPress® debug mode:
wp-config.php define('WP_DEBUG', true);define('WP_DEBUG_LOG', true);define('SCRIPT_DEBUG', true); -
Check browser console for JavaScript errors
-
Inspect block attributes:
- Click block in editor
- Open DevTools → Console
- Type:
wp.data.select('core/block-editor').getSelectedBlock() - Verify attributes are populated correctly
Verification
Section titled “Verification”After applying fixes:
- Refresh block editor (Ctrl+Shift+R / Cmd+Shift+R)
- Add Commerce Connect block to page
- Verify block appears in editor with preview
- Configure block settings (product selection, layout, etc.)
- Preview/publish page to check frontend rendering
- Inspect frontend HTML for block markup
Success indicators:
- Block appears in editor block inserter
- Block preview shows in editor (not empty box)
- Block settings panel shows configuration options
- Frontend shows product data with correct styling
- No JavaScript errors in browser console
- CSS styles applied correctly
Prevention
Section titled “Prevention”Maintain Build Process
Section titled “Maintain Build Process”- Run
npm run buildafter plugin updates - Commit
build/directory to version control - Verify assets exist before deploying to production
- Use
npm ciinstead ofnpm installfor consistent builds
Test Block Compatibility
Section titled “Test Block Compatibility”- Test blocks with active theme before going live
- Check editor and frontend rendering
- Test responsive layouts on mobile/tablet
- Verify accessibility (keyboard nav, screen readers)
Monitor Asset Loading
Section titled “Monitor Asset Loading”- Enable query monitor plugin (optional) to track enqueued scripts
- Check Network tab for 404 errors on block assets
- Verify CDN/caching not blocking block assets
- Test with caching disabled if layout issues occur
Document Block Requirements
Section titled “Document Block Requirements”For client/team documentation:
- List parent-child block relationships clearly
- Note any theme requirements (theme.json support, etc.)
- Document required plugins (none currently, but may change)
- Provide block usage examples with screenshots
Advanced Debugging
Section titled “Advanced Debugging”Inspect Block Registration
Section titled “Inspect Block Registration”Check which blocks are registered:
wp eval '$registry = WP_Block_Type_Registry::get_instance();$blocks = $registry->get_all_registered();foreach($blocks as $name => $block) { if(strpos($name, "commerce-connect") !== false) { echo "$name\n"; }}'Check Block Dependencies
Section titled “Check Block Dependencies”Verify block script dependencies:
wp eval '$block_type = WP_Block_Type_Registry::get_instance() ->get_registered("commerce-connect/product-grid");print_r($block_type->editor_script_handles);print_r($block_type->view_script_handles);'Should include commerce-connect-commons in dependencies.
Block Discovery Process
Section titled “Block Discovery Process”Understanding how blocks are found:
- Plugin scans
build/directory recursively - Looks for
block.jsonfiles at any depth - Registers each block found via
register_block_type() - Adds dependencies: Editor styles + commons chunk
- Creates category “Commerce Connect” for grouping
If blocks not appearing:
- Check
build/directory has proper structure - Verify
block.jsonexists and is valid JSON - Look for PHP errors during plugin activation
- Check plugin is active and not in “must-use plugins”
CSS Variable Mapping
Section titled “CSS Variable Mapping”Block styles depend on theme CSS variables:
/* Generated from theme.json */:root { --ecom-ui-primary-button-color-background: var(--wp--preset--color--primary); --ecom-ui-primary-button-color-text: var(--wp--preset--color--contrast); --ecom-ui-heading-h1-font-family: var(--wp--preset--font-family--heading); /* ... */}If variables missing:
- Theme doesn’t use theme.json - Blocks will use fallback defaults
- Theme.json missing settings - Specific styles won’t map
- Solution: Add missing settings to theme.json or use plugin settings override
Common Block.json Issues
Section titled “Common Block.json Issues”Invalid block.json causes registration to fail:
{ "apiVersion": 2, "name": "commerce-connect/product-grid", "title": "Product Grid", "category": "commerce-connect", "editorScript": "file:./index.js", "style": "file:./style-index.css"}Required fields:
apiVersion- Must be 2 or 3name- Must be unique and namespacedtitle- Display name in editorcategory- Must exist (commerce-connect is registered by plugin)
Verify with:
cat build/product-grid/block.json | jq '.'