Skip to content

Latest commit

 

History

History
48 lines (37 loc) · 1.34 KB

File metadata and controls

48 lines (37 loc) · 1.34 KB

WooCommerce Product Exporter (JSON)

A WordPress snippet to export all WooCommerce products in JSON format. The script enables admins to download a products.json file containing product details such as ID, name, price, SKU, description, stock, categories, tags, and image URLs.

Features

  • Exports all WooCommerce products in a single JSON file.
  • Includes essential product details:
    • Product ID
    • Name
    • Price
    • SKU
    • Description
    • Stock quantity
    • Categories
    • Tags
    • Product image URL
  • Restricted access to administrators only for security.

Installation

  1. Add the PHP snippet to your WordPress theme's functions.php file (also can create your own plugin).

Usage

To export products, visit your website with the following URL while logged in as an administrator: https://yourcoolwebsite.com/?export_products=json

This will trigger a download of a file named products.json.

JSON Format Example

The exported JSON file will look like this:

[
    {
        "id": 1,
        "name": "Sample Product",
        "price": "29.99",
        "sku": "SKU123",
        "description": "This is a sample product description.",
        "stock": 10,
        "categories": ["Category 1", "Category 2"],
        "tags": ["Tag 1", "Tag 2"],
        "image": "https://yourwebsite.com/wp-content/uploads/2024/01/sample.jpg"
    }
]