0
0
WordpressHow-ToBeginner · 4 min read

How to Add Product in WooCommerce in WordPress Easily

To add a product in WooCommerce on WordPress, go to your WordPress dashboard, navigate to Products > Add New, then enter the product details like name, description, price, and images. Finally, click Publish to make the product live on your store.
📐

Syntax

Adding a product in WooCommerce involves using the WordPress admin interface or programmatically creating a product with PHP code. The main parts are:

  • Product Title: The name of your product.
  • Description: Details about the product.
  • Product Data: Includes price, inventory, shipping, and more.
  • Product Image: The main picture for the product.
  • Publish: Save and make the product visible on your site.
php
function add_simple_product() {
  $product = new WC_Product_Simple();
  $product->set_name('Sample Product');
  $product->set_regular_price('19.99');
  $product->set_description('This is a sample product description.');
  $product->save();
}
💻

Example

This example shows how to add a simple product programmatically in WooCommerce using PHP. It sets the product name, price, and description, then saves it to your store.

php
<?php
function add_simple_product() {
  $product = new WC_Product_Simple();
  $product->set_name('Blue T-Shirt');
  $product->set_regular_price('25.00');
  $product->set_description('Comfortable blue t-shirt made of cotton.');
  $product->set_sku('BLUE-TSHIRT-001');
  $product->save();
}

add_action('init', 'add_simple_product');
?>
Output
A new product named 'Blue T-Shirt' appears in your WooCommerce products list with price $25.00 and the given description.
⚠️

Common Pitfalls

Common mistakes when adding products in WooCommerce include:

  • Not setting a price, which can cause the product not to show on the shop page.
  • Forgetting to publish the product after adding details.
  • Not assigning a product category, making it harder to find.
  • Using incorrect SKU formats that conflict with existing products.
  • Trying to add products programmatically without loading WooCommerce classes properly.
php
/* Wrong way: Missing price */
$product = new WC_Product_Simple();
$product->set_name('No Price Product');
$product->save();

/* Right way: Set price before saving */
$product = new WC_Product_Simple();
$product->set_name('Correct Product');
$product->set_regular_price('10.00');
$product->save();
📊

Quick Reference

StepAction
1Go to WordPress Dashboard > Products > Add New
2Enter product title and description
3Set product data (price, inventory, shipping)
4Add product images and categories
5Click Publish to add product to your store

Key Takeaways

Use the WordPress admin panel under Products > Add New to add products easily.
Always set a price and publish the product to make it visible in your store.
Programmatic product creation requires WooCommerce classes and proper hooks.
Assign categories and images to help customers find and see your products.
Check for SKU uniqueness and complete product data to avoid errors.