W
WordPress SOPKnowledge Base
Search
← All topics

WooCommerce Setup Essentials

runnable

WooCommerce installation sequence, essential wp-config.php settings for memory and revisions, key WooCommerce hooks for customizing product pages and checkout fields, WP-CLI WooCommerce commands, and performance optimizations.

woocommerceecommercesetupproductswp-cli
Agent trigger phrases: woocommerce setup · install woocommerce · woocommerce wp-config · woocommerce hooks · woocommerce performance · wc product create wp-cli · woocommerce cart fragments

WooCommerce setup sequence. Get foundations right before adding products.

Install Sequence

  1. Install WooCommerce plugin > Run setup wizard
  2. Set store location, currency, and tax options
  3. Add payment gateways (Stripe + PayPal minimum)
  4. Configure shipping zones and rates
  5. Enable automated tax or manually set rates
  6. Install Storefront theme or Elementor WooCommerce kit
  7. Wizard auto-creates: Shop, Cart, Checkout, My Account pages

Essential wp-config.php Settings

// Increase limits for WooCommerce
define('WP_MEMORY_LIMIT', '256M');
define('WP_MAX_MEMORY_LIMIT', '512M');

// Limit product revisions (reduces DB bloat)
add_filter('wp_revisions_to_keep', function($num, $post) {
    return $post->post_type === 'product' ? 3 : $num;
}, 10, 2);

Key WooCommerce Hooks

// Add content after product summary (priority 15 = after price)
add_action('woocommerce_after_single_product_summary', 'add_trust_badges', 15);
function add_trust_badges() {
    echo '<div class="trust-badges">Free shipping on orders over $50</div>';
}

// Change add-to-cart button text
add_filter('woocommerce_product_single_add_to_cart_text', function() {
    return 'Buy Now';
});

// Remove unnecessary checkout fields
add_filter('woocommerce_checkout_fields', function($fields) {
    unset($fields['billing']['billing_company']);
    unset($fields['billing']['billing_address_2']);
    unset($fields['order']['order_comments']);
    return $fields;
});

WP-CLI WooCommerce Operations

# List products
wp wc product list --user=admin

# Create a simple product
wp wc product create \
  --name="Service Package" \
  --type=simple \
  --regular_price=299 \
  --status=publish \
  --user=admin

# List pending orders
wp wc order list --status=pending --user=admin

# Clean up WooCommerce sessions
wp wc tools run cleanup_sessions --user=admin

Performance Optimizations

| Issue | Fix | |-------|-----| | Slow pages from cart fragments JS | Perfmatters > Disable cart fragments on non-shop pages | | Too many product variations | Keep under 50 per product | | DB bloat from sessions | Run cleanup_sessions weekly via WP-CLI or cron | | High memory usage | Ensure PHP 8.1+, 256MB RAM minimum | | Slow checkout | Enable WooCommerce block-based checkout |