Quick Start (Developer)
Get started with Commerce Connect development by building your first customization. This guide walks you through the architecture, hooks, and custom block development.
What You’ll Accomplish
Section titled “What You’ll Accomplish”By the end of this guide, you’ll have:
- ✅ Understanding of Commerce Connect architecture
- ✅ First custom hook implemented
- ✅ Custom block created and working
- ✅ Development environment configured
Prerequisites
Section titled “Prerequisites”- WordPress development environment (Local, Lando, or similar)
- Commerce Connect plugin installed and connected to BigCommerce
- Basic knowledge of WordPress hooks and React
- Code editor (VS Code, PHPStorm, etc.)
Step 1: Understand the Architecture
Section titled “Step 1: Understand the Architecture”Commerce Connect creates a bridge between WordPress and BigCommerce:
┌──────────────┐ ┌────────────────────┐ ┌──────────────┐│ │ │ │ │ ││ BigCommerce │────▶│ Commerce Connect │────▶│ WordPress ││ (Source) │ │ (Bridge + Cache) │ │ (Display) ││ │◀────│ │◀────│ │└──────────────┘ └────────────────────┘ └──────────────┘ │ │ │ │ │ │ Products Webhooks + API FSE Blocks Checkout Product Cache Content Pages Orders Sync Engine SEO OutputKey Concepts
Section titled “Key Concepts”Data Flow:
- Products live in BigCommerce (source of truth)
- Commerce Connect syncs product data to WordPress via BigCommerce API
- Product data cached in WordPress custom post types
- Blocks render cached data for fast page loads
- “Add to Cart” / “Checkout” redirect to BigCommerce hosted checkout
Why This Architecture?
- BigCommerce strengths: Commerce, payments, PCI compliance, fraud protection
- WordPress strengths: Content, SEO, page building, marketing
- Commerce Connect: Combines both platforms’ strengths
Step 2: Explore the Hooks System
Section titled “Step 2: Explore the Hooks System”Commerce Connect provides 27+ hooks for customization. Let’s implement one.
Example: Modify Product Price Display
Section titled “Example: Modify Product Price Display”Goal: Add “(Special Offer!)” text to sale prices.
Hook: commerce_connect_product_price_html
Implementation:
<?php/** * Plugin Name: Commerce Connect - Price Customization * Description: Add "Special Offer!" to sale prices * Version: 1.0.0 */
add_filter('commerce_connect_product_price_html', 'add_special_offer_text', 10, 2);
function add_special_offer_text($price_html, $product) { // Check if product is on sale if ($product->sale_price && $product->sale_price < $product->calculated_price) { // Add special offer badge $price_html .= ' <span class="special-offer-badge" style="color: #e74c3c; font-weight: bold;">(Special Offer!)</span>'; }
return $price_html;}Install:
- Create file:
wp-content/mu-plugins/cc-price-customization.php - Paste code above
- Reload any product page
Result: Sale prices now show “(Special Offer!)” badge.
Available Hook Categories
Section titled “Available Hook Categories”Product Hooks (9):
commerce_connect_product_data- Modify product data before displaycommerce_connect_product_price_html- Customize price formattingcommerce_connect_product_title- Modify product titles- View all product hooks →
Block Hooks (7):
commerce_connect_block_attributes- Modify block attributescommerce_connect_block_render- Customize block output- View all block hooks →
Sync Hooks (6):
commerce_connect_before_product_sync- Run code before synccommerce_connect_after_product_sync- Run code after sync- View all sync hooks →
API Hooks (5):
commerce_connect_api_request- Modify API requestscommerce_connect_api_response- Process API responses- View all API hooks →
Full reference: Hooks & Filters
Step 3: Build a Custom Block
Section titled “Step 3: Build a Custom Block”Now create a custom block that displays product stock status.
Block Structure
Section titled “Block Structure”my-custom-block/├── src/│ ├── index.js # Block registration│ ├── edit.js # Editor component│ ├── save.js # Frontend output│ └── style.scss # Block styles├── block.json # Block metadata└── package.json # Dependencies1. Create Block Directory
Section titled “1. Create Block Directory”cd wp-content/pluginsmkdir cc-stock-status-blockcd cc-stock-status-block2. Initialize Block
Section titled “2. Initialize Block”npm init -ynpm install @wordpress/scripts @wordpress/blocks @wordpress/block-editor --save-dev3. Create block.json
Section titled “3. Create block.json”{ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "commerce-connect/stock-status", "title": "Product Stock Status", "category": "commerce-connect", "icon": "products", "description": "Display product stock availability with visual indicator", "supports": { "html": false, "align": true }, "attributes": { "productId": { "type": "number", "default": 0 }, "showQuantity": { "type": "boolean", "default": true } }, "textdomain": "commerce-connect-stock", "editorScript": "file:./build/index.js", "editorStyle": "file:./build/index.css", "style": "file:./build/style-index.css"}4. Create src/index.js
Section titled “4. Create src/index.js”import { registerBlockType } from '@wordpress/blocks';import Edit from './edit';import save from './save';import './style.scss';
registerBlockType('commerce-connect/stock-status', { edit: Edit, save,});5. Create src/edit.js
Section titled “5. Create src/edit.js”import { useBlockProps, InspectorControls } from '@wordpress/block-editor';import { PanelBody, ToggleControl } from '@wordpress/components';import { useSelect } from '@wordpress/data';
export default function Edit({ attributes, setAttributes }) { const { productId, showQuantity } = attributes;
// Get product data from Commerce Connect store const product = useSelect( (select) => { return select('commerce-connect/products').getProduct(productId); }, [productId], );
const blockProps = useBlockProps();
return ( <> <InspectorControls> <PanelBody title="Stock Status Settings"> <ToggleControl label="Show Quantity" checked={showQuantity} onChange={(value) => setAttributes({ showQuantity: value })} /> </PanelBody> </InspectorControls>
<div {...blockProps}> {product ? ( <div className="stock-status"> <span className={`status-indicator ${product.inventory_level > 0 ? 'in-stock' : 'out-of-stock'}`}> {product.inventory_level > 0 ? '✓ In Stock' : '✗ Out of Stock'} </span> {showQuantity && product.inventory_level > 0 && ( <span className="quantity">({product.inventory_level} available)</span> )} </div> ) : ( <p>Select a product to display stock status</p> )} </div> </> );}6. Create src/save.js
Section titled “6. Create src/save.js”import { useBlockProps } from '@wordpress/block-editor';
export default function save({ attributes }) { const { productId, showQuantity } = attributes;
return ( <div {...useBlockProps.save()}> <div className="cc-stock-status" data-product-id={productId} data-show-quantity={showQuantity}> {/* Dynamic content rendered via PHP */} </div> </div> );}7. Create PHP Render Function
Section titled “7. Create PHP Render Function”Create cc-stock-status-block.php:
<?php/** * Plugin Name: Commerce Connect - Stock Status Block * Description: Display product stock availability * Version: 1.0.0 */
// Register blockfunction cc_stock_status_register_block() { register_block_type(__DIR__ . '/build', [ 'render_callback' => 'cc_stock_status_render', ]);}add_action('init', 'cc_stock_status_register_block');
// Render callbackfunction cc_stock_status_render($attributes) { $product_id = $attributes['productId'] ?? 0; $show_quantity = $attributes['showQuantity'] ?? true;
if (!$product_id) { return '<p>No product selected</p>'; }
// Get product from Commerce Connect $product = \WP_Engine\CommerceConnect\Products\Product::get($product_id);
if (!$product) { return '<p>Product not found</p>'; }
$in_stock = $product->inventory_level > 0; $status_class = $in_stock ? 'in-stock' : 'out-of-stock'; $status_text = $in_stock ? '✓ In Stock' : '✗ Out of Stock';
$html = sprintf( '<div class="cc-stock-status"><span class="status-indicator %s">%s</span>', esc_attr($status_class), esc_html($status_text) );
if ($show_quantity && $in_stock) { $html .= sprintf( ' <span class="quantity">(%d available)</span>', absint($product->inventory_level) ); }
$html .= '</div>';
return $html;}8. Build Block
Section titled “8. Build Block”npm run build9. Activate Plugin
Section titled “9. Activate Plugin”- Navigate to Plugins in WordPress admin
- Find “Commerce Connect - Stock Status Block”
- Click Activate
Result: New block available in block inserter under “Commerce Connect” category.
Step 4: Test Your Customization
Section titled “Step 4: Test Your Customization”Test the Hook
Section titled “Test the Hook”- Open any product page with a sale price
- Verify “(Special Offer!)” text appears after price
- Inspect element to confirm custom HTML
Test the Block
Section titled “Test the Block”- Create a new page
- Add “Product Stock Status” block
- Select a product
- Toggle “Show Quantity” setting
- Publish and verify frontend display
What’s Next?
Section titled “What’s Next?”Explore More Hooks
Section titled “Explore More Hooks”Recommended hooks to try:
commerce_connect_add_to_cart_url- Customize cart behaviorcommerce_connect_product_image_size- Control image sizescommerce_connect_sync_batch_size- Optimize sync performance
Full list: Hooks & Filters Reference
Build Advanced Blocks
Section titled “Build Advanced Blocks”Ideas for custom blocks:
- Product comparison table
- Recently viewed products
- Custom product filters
- Personalized product recommendations
Guide: Custom Blocks
Work with the API
Section titled “Work with the API”Query product data directly:
// Get single product$product = \WP_Engine\CommerceConnect\API\Client::get_product(123);
// Search products$results = \WP_Engine\CommerceConnect\API\Client::search_products([ 'keyword' => 'shoes', 'category' => 'footwear', 'min_price' => 50,]);
// Get variants$variants = \WP_Engine\CommerceConnect\API\Client::get_product_variants(123);Documentation: API Reference
Debug and Troubleshoot
Section titled “Debug and Troubleshoot”Enable debug mode:
define('CC_DEBUG', true);define('WP_DEBUG', true);define('WP_DEBUG_LOG', true);View debug logs:
tail -f wp-content/debug.logCommon issues:
Development Resources
Section titled “Development Resources”Official Documentation
Section titled “Official Documentation”- Architecture Overview - System design and data flow
- Hooks & Filters - Complete hooks reference (27+)
- Custom Blocks - Block development guide
- API Reference - REST API and PHP classes
Code Examples
Section titled “Code Examples”Browse real-world examples in the plugin source:
# Product blockswp-content/plugins/commerce-connect/blocks/product-*
# Sync enginewp-content/plugins/commerce-connect/includes/sync/
# API clientwp-content/plugins/commerce-connect/includes/api/Community Support
Section titled “Community Support”- WP Engine Support - Official support channel
- GitHub Issues - Bug reports and feature requests
- Developer Forums - Community discussions
Need Help?
Section titled “Need Help?”Common developer questions:
Still stuck? Contact WP Engine Support with your development question.