Install Package

composer require codexshaper/laravel-woocommerce

Publish config file

php artisan vendor:publish --tag=woocommerce
Add API credentials in your .env file

<?php 

WOOCOMMERCE_STORE_URL=YOUR_WEBSITE_URL
WOOCOMMERCE_CONSUMER_KEY=API_CONSUMER_KEY
WOOCOMMERCE_CONSUMER_SECRET=API_CONSUMER_SECRET
                            

Coupon

Properties

See all coupon properties from here https://woocommerce.github.io/woocommerce-rest-api-docs/#coupon-properties

Create a coupon

Import use Codexshaper\WooCommerce\Facades\Coupon; or simply use Coupon; To avoid conflict with other class use full qualified classes (with namespace).

Create simple coupon


<?php 

$data = [
    'code' => '10off',
    'discount_type' => 'percent',
    'amount' => '10',
    'individual_use' => true,
    'exclude_sale_items' => true,
    'minimum_amount' => '100.00'
];

$coupon = Coupon::create($data);
                  

Retrieve a coupon

Import use Codexshaper\WooCommerce\Facades\Coupon; or simply use Coupon; To avoid conflict with other class use full qualified classes (with namespace).

<?php
$coupon_id = 1;
$coupon = Coupon::find($coupon_id);
                        

Retrieve all coupons

Import use Codexshaper\WooCommerce\Facades\Coupon; or simply use Coupon; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$coupons = Coupon::all();
                    

Update a coupon

Import use Codexshaper\WooCommerce\Facades\Coupon; or simply use Coupon; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$coupon_id = 2;
$data = [
    'amount' => '5'
];

$custmer = Coupon::update($coupon_id, $data);
                    

Delete a coupon

Import use Codexshaper\WooCommerce\Facades\Coupon; or simply use Coupon; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$coupon_id = 40;
$options = ['force' => true]; // Set force option true for delete permanently. Default value false

$coupon = Coupon::delete($coupon_id, $options);
                    

Batch update coupons

Import use Codexshaper\WooCommerce\Facades\Coupon; or simply use Coupon; To avoid conflict with other class use full qualified classes (with namespace).
Create, Update and Delete in one command

<?php

$data = [
  'create' => [
      [
          'code' => '20off',
          'discount_type' => 'percent',
          'amount' => '20',
          'individual_use' => true,
          'exclude_sale_items' => true,
          'minimum_amount' => '100.00'
      ],
      [
          'code' => '30off',
          'discount_type' => 'percent',
          'amount' => '30',
          'individual_use' => true,
          'exclude_sale_items' => true,
          'minimum_amount' => '100.00'
      ]
  ],
  'update' => [
      [
          'id' => 719,
          'minimum_amount' => '50.00'
      ]
  ],
  'delete' => [
      720
  ]
];

$batch = Coupon::batch($data);

                      

Customer

Properties

See all customer properties from here https://woocommerce.github.io/woocommerce-rest-api-docs/#customer-properties

Create a customer

Import use Codexshaper\WooCommerce\Facades\Customer; or simply use Customer; To avoid conflict with other class use full qualified classes (with namespace).

Create simple customer


<?php 

$data = [
    'email' => 'john.doe@example.com',
    'first_name' => 'John',
    'last_name' => 'Doe',
    'username' => 'john.doe',
    'billing' => [
        'first_name' => 'John',
        'last_name' => 'Doe',
        'company' => '',
        'address_1' => '969 Market',
        'address_2' => '',
        'city' => 'San Francisco',
        'state' => 'CA',
        'postcode' => '94103',
        'country' => 'US',
        'email' => 'john.doe@example.com',
        'phone' => '(555) 555-5555'
    ],
    'shipping' => [
        'first_name' => 'John',
        'last_name' => 'Doe',
        'company' => '',
        'address_1' => '969 Market',
        'address_2' => '',
        'city' => 'San Francisco',
        'state' => 'CA',
        'postcode' => '94103',
        'country' => 'US'
    ]
];

$customer = Customer::create($data);
                  

Retrieve a customer

Import use Codexshaper\WooCommerce\Facades\Customer; or simply use Customer; To avoid conflict with other class use full qualified classes (with namespace).

<?php
$customer_id = 1;
$customer = Customer::find($customer_id);
                        

Retrieve all customers

Import use Codexshaper\WooCommerce\Facades\Customer; or simply use Customer; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$customers = Customer::all();
                    

Update a customer

Import use Codexshaper\WooCommerce\Facades\Customer; or simply use Customer; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$customer_id = 2;
$data = [
    'first_name' => 'James',
    'billing' => [
        'first_name' => 'James'
    ],
    'shipping' => [
        'first_name' => 'James'
    ]
];

$custmer = Customer::update($customer_id, $data);
                    

Delete a customer

Import use Codexshaper\WooCommerce\Facades\Customer; or simply use Customer; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$customer_id = 40;
$options = ['force' => true]; // Set force option true for delete permanently. Default value false

$customer = Customer::delete($customer_id, $options);
                    

Batch update customers

Import use Codexshaper\WooCommerce\Facades\Customer; or simply use Customer; To avoid conflict with other class use full qualified classes (with namespace).
Create, Update and Delete in one command

<?php

$data = [
    'create' => [
        [
            'email' => 'john.doe2@example.com',
            'first_name' => 'John',
            'last_name' => 'Doe',
            'username' => 'john.doe2',
            'billing' => [
                'first_name' => 'John',
                'last_name' => 'Doe',
                'company' => '',
                'address_1' => '969 Market',
                'address_2' => '',
                'city' => 'San Francisco',
                'state' => 'CA',
                'postcode' => '94103',
                'country' => 'US',
                'email' => 'john.doe@example.com',
                'phone' => '(555) 555-5555'
            ],
            'shipping' => [
                'first_name' => 'John',
                'last_name' => 'Doe',
                'company' => '',
                'address_1' => '969 Market',
                'address_2' => '',
                'city' => 'San Francisco',
                'state' => 'CA',
                'postcode' => '94103',
                'country' => 'US'
            ]
        ],
        [
            'email' => 'joao.silva2@example.com',
            'first_name' => 'João',
            'last_name' => 'Silva',
            'username' => 'joao.silva2',
            'billing' => [
                'first_name' => 'João',
                'last_name' => 'Silva',
                'company' => '',
                'address_1' => 'Av. Brasil, 432',
                'address_2' => '',
                'city' => 'Rio de Janeiro',
                'state' => 'RJ',
                'postcode' => '12345-000',
                'country' => 'BR',
                'email' => 'joao.silva@example.com',
                'phone' => '(55) 5555-5555'
            ],
            'shipping' => [
                'first_name' => 'João',
                'last_name' => 'Silva',
                'company' => '',
                'address_1' => 'Av. Brasil, 432',
                'address_2' => '',
                'city' => 'Rio de Janeiro',
                'state' => 'RJ',
                'postcode' => '12345-000',
                'country' => 'BR'
            ]
        ]
    ],
    'update' => [
        [
            'id' => 26,
            'billing' => [
                'phone' => '(11) 1111-1111'
            ]
        ]
    ],
    'delete' => [
        25
    ]
];

$batch = Customer::batch($data);

                      

Customer downloads

Import use Codexshaper\WooCommerce\Facades\Customer; or simply use Customer; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$customer_id = 40;
$downloads = Customer::downloads($customer_id);
                        

Payment Gateway

Properties

See all product properties from here https://woocommerce.github.io/woocommerce-rest-api-docs/#payment-gateway-properties

Create a product

Import use Codexshaper\WooCommerce\Facades\PaymentGateway; or simply use PaymentGateway; To avoid conflict with other class use full qualified classes (with namespace).

Retrieve an payment gateway

Import use Codexshaper\WooCommerce\Facades\PaymentGateway; or simply use PaymentGateway; To avoid conflict with other class use full qualified classes (with namespace).

<?php
$name = 'bacs';
$paymentGateway = PaymentGateway::find($name);
                        

Retrieve all payment gateways

Import use Codexshaper\WooCommerce\Facades\PaymentGateway; or simply use PaymentGateway; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$paymentGateways = PaymentGateway::all();
                    

Update an payment gateway

Import use Codexshaper\WooCommerce\Facades\PaymentGateway; or simply use PaymentGateway; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$name = 'bacs';
$data = [
    'enabled' => true
];

$paymentGateway = PaymentGateway::update($name, $data);
                    

Product

Properties

See all product properties from here https://woocommerce.github.io/woocommerce-rest-api-docs/#product-properties

Create a product

Import use Codexshaper\WooCommerce\Facades\Product; or simply use Product; To avoid conflict with other class use full qualified classes (with namespace).

Create simple product


<?php 

$data = [
    'name' => 'Simple Product',
    'type' => 'simple',
    'regular_price' => '10.00',
    'description' => 'Simple product full description.',
    'short_description' => 'Simple product short description.',
    'categories' => [
        [
            'id' => 1
        ],
        [
            'id' => 3
        ],
        [
            'id' => 5
        ]
    ],
    'images' => [
        [
            'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg'
        ],
        [
            'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg'
        ]
    ]
];

$product = Product::create($data);
            

Create variable product


<?php 

$data = [
    'name' => 'Variable Product',
    'type' => 'variable',
    'description' => 'Variable product full description.',
    'short_description' => 'Variable product short description.',
    'categories' => [
        [
          'id' => 1
        ],
        [
          'id' => 3
        ],
        [
          'id' => 5
        ]
    ],
    'images' => [
        [
            'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg'
        ],
        [
            'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_back.jpg'
        ],
        [
            'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg'
        ],
        [
            'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_back.jpg'
        ]
    ],
    'attributes' => [
        [
            'id' => 6,
            'position' => 0,
            'visible' => false,
            'variation' => true,
            'options' => [
                'Black',
                'Green'
            ]
        ],
        [
            'name' => 'Size',
            'position' => 0,
            'visible' => true,
            'variation' => true,
            'options' => [
                'S',
                'M'
            ]
        ]
    ],
    'default_attributes' => [
        [
            'id' => 6,
            'option' => 'Black'
        ],
        [
            'name' => 'Size',
            'option' => 'S'
        ]
    ]
];

$product = Product::create($data);
            

Create like laravel eloquent


<?php 

$categories = [
    [
        'id' => 1,
    ],
    [
        'id' => 3,
    ],
];

$images = [
    [
        'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg',
    ],
    [
        'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg',
    ],
];

$product                    = new Product;
$product->name              = 'Product Eloquent 2';
$product->type              = 'simple';
$product->regular_price     = '100';
$product->sale_price        = '50';
$product->description       = 'Product Description';
$product->short_description = 'Product Short Description';
$product->categories        = $categories;
$product->images            = $images;
$product->save();
                            

Retrieve a product

Import use Codexshaper\WooCommerce\Facades\Product; or simply use Product; To avoid conflict with other class use full qualified classes (with namespace).

<?php
$product_id = 1;
$product = Product::find($product_id);
                        

Retrieve all products

Import use Codexshaper\WooCommerce\Facades\Product; or simply use Product; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$products = Product::all();
                    

Update a product

Import use Codexshaper\WooCommerce\Facades\Product; or simply use Product; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$product_id = 40;
$data       = [
    'regular_price' => '50',
    'sale_price'    => '25', // 50% off
];

$product = Product::update($product_id, $data);
                    

Delete a product

Import use Codexshaper\WooCommerce\Facades\Product; or simply use Product; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$product_id = 40;
$options = ['force' => true]; // Set force option true for delete permanently. Default value false

$product = Product::delete($product_id, $options);
                    

Batch update products

Import use Codexshaper\WooCommerce\Facades\Product; or simply use Product; To avoid conflict with other class use full qualified classes (with namespace).
Create, Update and Delete in one command

<?php

$data = [
    'create' => [
        [
            'name' => 'Woo Single #1',
            'type' => 'simple',
            'regular_price' => '21.99',
            'virtual' => true,
            'downloadable' => true,
            'downloads' => [
                [
                    'name' => 'Woo Single',
                    'file' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg'
                ]
            ],
            'categories' => [
                [
                    'id' => 11
                ],
                [
                    'id' => 13
                ]
            ],
            'images' => [
                [
                    'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg'
                ]
            ]
        ],
        [
            'name' => 'New Premium Quality',
            'type' => 'simple',
            'regular_price' => '21.99',
            'description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.',
            'short_description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.',
            'categories' => [
                [
                    'id' => 9
                ],
                [
                    'id' => 14
                ]
            ],
            'images' => [
                [
                    'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg'
                ],
                [
                    'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg'
                ]
            ]
        ]
    ],
    'update' => [
        [
            'id' => 799,
            'default_attributes' => [
                [
                    'id' => 6,
                    'name' => 'Color,
                    'option' => 'Green'
                ],
                [
                    'id' => 0,
                    'name' => 'Size',
                    'option' => 'M'
                ]
            ]
        ]
    ],
    'delete' => [
        794
    ]
];

$batch = Product::batch($data);

                    

variation

Properties

See all variation properties from here https://woocommerce.github.io/woocommerce-rest-api-docs/#product-variation-properties

Create an variation

Import use Codexshaper\WooCommerce\Facades\Variation; or simply use Variation; To avoid conflict with other class use full qualified classes (with namespace).

<?php 

$product_id = 70;
$data = [
    'regular_price' => '9.00',
    'image' => [
        'id' => 423
    ],
    'attributes' => [
        [
            'id' => 9,
            'option' => 'Black'
        ]
    ]
];

$variation = Variation::create($product_id, $data);
              

Retrieve an variation

Import use Codexshaper\WooCommerce\Facades\Variation; or simply use Variation; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$product_id = 70;
$variation_id = 1;
$variation = Variation::find($product_id, $variation_id);
                        

Retrieve all variations

Import use Codexshaper\WooCommerce\Facades\Variation; or simply use Variation; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$product_id = 70;
$variations = Variation::all($product_id);
                    

Update an variation

Import use Codexshaper\WooCommerce\Facades\Variation; or simply use Variation; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$product_id = 70;
$variation_id = 173;
$data = [
    'regular_price' => '10.00'
];

$variation = Variation::update($product_id, $variation_id, $data);
                    

Delete an variation

Import use Codexshaper\WooCommerce\Facades\Variation; or simply use Variation; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$product_id = 70;
$variation_id = 173;
$options = ['force' => true]; // Set force option true for delete permanently. Default value false

$variation = Variation::delete($product_id, $variation_id, $options);
                    

Batch update variations

Import use Codexshaper\WooCommerce\Facades\Variation; or simply use Variation; To avoid conflict with other class use full qualified classes (with namespace).
Create, Update and Delete in one command

<?php

$data = [
    'create' => [
        [
            'regular_price' => '10.00',
            'attributes' => [
                [
                    'id' => 6,
                    'option' => 'Blue'
                ]
            ]
        ],
        [
            'regular_price' => '10.00',
            'attributes' => [
                [
                    'id' => 6,
                    'option' => 'White'
                ]
            ]
        ]
    ],
    'update' => [
        [
            'id' => 733,
            'regular_price' => '10.00'
        ]
    ],
    'delete' => [
        732
    ]
];

$product_id = 70;

$batch = Variation::batch($product_id, $data);

                    

attribute

Properties

See all attribute properties from here https://woocommerce.github.io/woocommerce-rest-api-docs/#product-attribute-properties

Create an attribute

Import use Codexshaper\WooCommerce\Facades\Attribute; or simply use Attribute; To avoid conflict with other class use full qualified classes (with namespace).

<?php 

$data = [
    'name' => 'Color',
    'slug' => 'pa_color',
    'type' => 'select',
    'order_by' => 'menu_order',
    'has_archives' => true
];

$attribute = Attribute::create($data);
              

Retrieve an attribute

Import use Codexshaper\WooCommerce\Facades\Attribute; or simply use Attribute; To avoid conflict with other class use full qualified classes (with namespace).

<?php
$attribute_id = 1;
$attribute = Attribute::find($attribute_id);
                        

Retrieve all attributes

Import use Codexshaper\WooCommerce\Facades\Attribute; or simply use Attribute; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$attributes = Attribute::all();
                    

Update an attribute

Import use Codexshaper\WooCommerce\Facades\Attribute; or simply use Attribute; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$attribute_id = 173;
$data = [
    'order_by' => 'name'
];

$attribute = Attribute::update($attribute_id, $data);
                    

Delete an attribute

Import use Codexshaper\WooCommerce\Facades\Attribute; or simply use Attribute; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$attribute_id = 173;
$options = ['force' => true]; // Set force option true for delete permanently. Default value false

$attribute = Attribute::delete($attribute_id, $options);
                    

Batch update attributes

Import use Codexshaper\WooCommerce\Facades\Attribute; or simply use Attribute; To avoid conflict with other class use full qualified classes (with namespace).
Create, Update and Delete in one command

<?php

$data = [
    'create' => [
        [
            'name' => 'Brand'
        ],
        [
            'name' => 'Publisher'
        ]
    ],
    'update' => [
        [
            'id' => 2,
            'order_by' => 'name'
        ]
    ],
    'delete' => [
        1
    ]
];

$batch = Attribute::batch($data);

                    

Attribute Term

Properties

See all term properties from here https://woocommerce.github.io/woocommerce-rest-api-docs/#product-attribute-term-properties

Create a term

Import use Codexshaper\WooCommerce\Facades\Term; or simply use Term; To avoid conflict with other class use full qualified classes (with namespace).

<?php 

$attribute_id = 1;
$data = [
    'name' => 'Color',
    'slug' => 'pa_color',
    'type' => 'select',
    'order_by' => 'menu_order',
    'has_archives' => true
];

$term = Term::create($attribute_id, $data);
OR
$term = Attribute::addTerm($attribute_id, $data);
              

Retrieve a term

Import use Codexshaper\WooCommerce\Facades\Term; or simply use Term; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$attribute_id = 1;
$term_id = 5;

$term = Term::find($attribute_id, $term_id);
OR
$term = Attribute::getTerm($attribute_id, $term_id);
                        

Retrieve all terms

Import use Codexshaper\WooCommerce\Facades\Term; or simply use Term; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$attribute_id = 1;

$terms = Term::all($attribute_id);
OR
$terms = Attribute::getTerms($attribute_id);
                    

Update a term

Import use Codexshaper\WooCommerce\Facades\Term; or simply use Term; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$attribute_id = 1;
$term_id = 173;
$data = [
    'name' => 'XXS'
];

$term = Term::update($attribute_id, $term_id, $data);
OR
$term = Attribute::updateTerm($attribute_id, $term_id, $data);
                    

Delete a term

Import use Codexshaper\WooCommerce\Facades\Term; or simply use Term; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$attribute_id = 1;
$term_id = 173;
$options = ['force' => true]; // Set force option true for delete permanently. Default value false

$term = Term::delete($attribute_id, $term_id, $options);
OR
$term = Attribute::deleteTerm($attribute_id, $term_id, $options);
                    

Batch update terms

Import use Codexshaper\WooCommerce\Facades\Term; or simply use Term; To avoid conflict with other class use full qualified classes (with namespace).
Create, Update and Delete in one command

<?php

$attribute_id = 1;
$data = [
    'create' => [
        [
            'name' => 'XXS'
        ],
        [
            'name' => 'S'
        ]
    ],
    'update' => [
        [
            'id' => 19,
            'menu_order' => 6
        ]
    ],
    'delete' => [
        21,
        20
    ]
];

$batch = Term::batch($attribute_id, $data);
OR
$batch = Attribute::batch($attribute_id, $data);

                    

category

Properties

See all category properties from here https://woocommerce.github.io/woocommerce-rest-api-docs/#product-category-properties

Create an category

Import use Codexshaper\WooCommerce\Facades\Category; or simply use Category; To avoid conflict with other class use full qualified classes (with namespace).

<?php 

$data = [
    "name' => 'Clothing',
    'image' => [
        'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg'
    ]
];

$category = Category::create($data);
              

Retrieve a category

Import use Codexshaper\WooCommerce\Facades\Category; or simply use Category; To avoid conflict with other class use full qualified classes (with namespace).

<?php
$category_id = 1;
$category = Category::find($category_id);
                        

Retrieve all categorys

Import use Codexshaper\WooCommerce\Facades\Category; or simply use Category; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$categorys = Category::all();
                    

Update a category

Import use Codexshaper\WooCommerce\Facades\Category; or simply use Category; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$category_id = 173;
$data = [
    'description' => 'All kinds of clothes.'
];

$category = Category::update($category_id, $data);
                    

Delete a category

Import use Codexshaper\WooCommerce\Facades\Category; or simply use Category; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$category_id = 173;
$options = ['force' => true]; // Set force option true for delete permanently. Default value false

$category = Category::delete($category_id, $options);
                    

Batch update categorys

Import use Codexshaper\WooCommerce\Facades\Category; or simply use Category; To avoid conflict with other class use full qualified classes (with namespace).
Create, Update and Delete in one command

<?php

$data = [
    'create' => [
        [
            'name' => 'Albums'
        ],
        [
            'name' => 'Clothing'
        ]
    ],
    'update' => [
        [
            'id' => 10,
            'description' => 'Nice hoodies'
        ]
    ],
    'delete' => [
        11,
        12
    ]
];
$batch = Category::batch($data);

                    

tag

Properties

See all tag properties from here https://woocommerce.github.io/woocommerce-rest-api-docs/#product-tag-properties

Create an tag

Import use Codexshaper\WooCommerce\Facades\Tag; or simply use Tag; To avoid conflict with other class use full qualified classes (with namespace).

<?php 

$data = [
    'name' => 'Leather Shoes'
];

$tag = Tag::create($data);
              

Retrieve a tag

Import use Codexshaper\WooCommerce\Facades\Tag; or simply use Tag; To avoid conflict with other class use full qualified classes (with namespace).

<?php
$tag_id = 1;
$tag = Tag::find($tag_id);
                        

Retrieve all tags

Import use Codexshaper\WooCommerce\Facades\Tag; or simply use Tag; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$tags = Tag::all();
                    

Update a tag

Import use Codexshaper\WooCommerce\Facades\Tag; or simply use Tag; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$tag_id = 173;
$data = [
    'description': 'Genuine leather.'
];

$tag = Tag::update($tag_id, $data);
                    

Delete a tag

Import use Codexshaper\WooCommerce\Facades\Tag; or simply use Tag; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$tag_id = 173;
$options = [
  'force' => true // Set force option true for delete permanently. Default value false
]; 

$tag = Tag::delete($tag_id, $options);
                    

Batch update tags

Import use Codexshaper\WooCommerce\Facades\Tag; or simply use Tag; To avoid conflict with other class use full qualified classes (with namespace).
Create, Update and Delete in one command

<?php

$data = [
    'create' => [
        [
            'name' => 'Round toe'
        ],
        [
            'name' => 'Flat'
        ]
    ],
    'update' => [
        [
            'id' => 34,
            'description' => 'Genuine leather.'
        ]
    ],
    'delete' => [
        35
    ]
];

$batch = Tag::batch($data);

                    

review

Properties

See all review properties from here https://woocommerce.github.io/woocommerce-rest-api-docs/#product-review-properties

Create an review

Import use Codexshaper\WooCommerce\Facades\Review; or simply use Review; To avoid conflict with other class use full qualified classes (with namespace).

<?php 

$data = [
    'product_id' => 22,
    'review' => 'Nice album!',
    'reviewer' => 'John Doe',
    'reviewer_email' => 'john.doe@example.com',
    'rating' => 5
];

$review = Review::create($data);
              

Retrieve a review

Import use Codexshaper\WooCommerce\Facades\Review; or simply use Review; To avoid conflict with other class use full qualified classes (with namespace).

<?php
$review_id = 1;
$review = Review::find($review_id);
                        

Retrieve all reviews

Import use Codexshaper\WooCommerce\Facades\Review; or simply use Review; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$reviews = Review::all();
                    

Update a review

Import use Codexshaper\WooCommerce\Facades\Review; or simply use Review; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$review_id = 173;
$data = [
    'rating': 5
];

$review = Review::update($review_id, $data);
                    

Delete a review

Import use Codexshaper\WooCommerce\Facades\Review; or simply use Review; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$review_id = 173;
$options = [
  'force' => true // Set force option true for delete permanently. Default value false
]; 

$review = Review::delete($review_id, $options);
                    

Batch update reviews

Import use Codexshaper\WooCommerce\Facades\Review; or simply use Review; To avoid conflict with other class use full qualified classes (with namespace).
Create, Update and Delete in one command

<?php

$data = [
    'create' => [
        [
            'product_id' => 22,
            'review' => 'Looks fine',
            'reviewer' => 'John Doe',
            'reviewer_email' => 'john.doe@example.com',
            'rating' => 4
        ],
        [
            'product_id' => 22,
            'review' => 'I love this album',
            'reviewer' => 'John Doe',
            'reviewer_email' => 'john.doe@example.com',
            'rating' => 5
        ]
    ],
    'update' => [
        [
            'id' => 7,
            'reviewer' => 'John Doe',
            'reviewer_email' => 'john.doe@example.com',
        ]
    ],
    'delete' => [
        22
    ]
];

$batch = Review::batch($data);

                    

Order

Properties

See all order properties from here https://woocommerce.github.io/woocommerce-rest-api-docs/#order-properties

Create an order

Import use Codexshaper\WooCommerce\Facades\Order; or simply use Order; To avoid conflict with other class use full qualified classes (with namespace).

<?php 

$data = [
    'payment_method'       => 'bacs',
    'payment_method_title' => 'Direct Bank Transfer',
    'set_paid'             => true,
    'billing'              => [
        'first_name' => 'John',
        'last_name'  => 'Doe',
        'address_1'  => '969 Market',
        'address_2'  => '',
        'city'       => 'San Francisco',
        'state'      => 'CA',
        'postcode'   => '94103',
        'country'    => 'US',
        'email'      => 'john.doe@example.com',
        'phone'      => '(555) 555-5555',
    ],
    'shipping'             => [
        'first_name' => 'John',
        'last_name'  => 'Doe',
        'address_1'  => '969 Market',
        'address_2'  => '',
        'city'       => 'San Francisco',
        'state'      => 'CA',
        'postcode'   => '94103',
        'country'    => 'US',
    ],
    'line_items'           => [
        [
            'product_id' => 40,
            'quantity'   => 2,
        ],
        [
            'product_id'   => 127,
            'variation_id' => 23,
            'quantity'     => 1,
        ],
    ],
];

$order = Order::create($data);
              

Retrieve a order

Import use Codexshaper\WooCommerce\Facades\Order; or simply use Order; To avoid conflict with other class use full qualified classes (with namespace).

<?php
$order_id = 1;
$order = Order::find($order_id);
                        

Retrieve all orders

Import use Codexshaper\WooCommerce\Facades\Order; or simply use Order; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$orders = Order::all();
                    

Update an order

Import use Codexshaper\WooCommerce\Facades\Order; or simply use Order; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$order_id = 173;
$data     = [
    'status' => 'completed',
];

$order = Order::update($order_id, $data);
                    

Delete an order

Import use Codexshaper\WooCommerce\Facades\Order; or simply use Order; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$order_id = 173;
$options = ['force' => true]; // Set force option true for delete permanently. Default value false

$order = Order::delete($order_id, $options);
                    

Batch update orders

Import use Codexshaper\WooCommerce\Facades\Order; or simply use Order; To avoid conflict with other class use full qualified classes (with namespace).
Create, Update and Delete in one command

<?php

$data = [
    'create' => [
        [
            'payment_method' => 'bacs',
            'payment_method_title' => 'Direct Bank Transfer',
            'billing' => [
                'first_name' => 'John',
                'last_name' => 'Doe',
                'address_1' => '969 Market',
                'address_2' => '',
                'city' => 'San Francisco',
                'state' => 'CA',
                'postcode' => '94103',
                'country' => 'US',
                'email' => 'john.doe@example.com',
                'phone' => '(555) 555-5555'
            ],
            'shipping' => [
                'first_name' => 'John',
                'last_name' => 'Doe',
                'address_1' => '969 Market',
                'address_2' => '',
                'city' => 'San Francisco',
                'state' => 'CA',
                'postcode' => '94103',
                'country' => 'US'
            ],
            'line_items' => [
                [
                    'product_id' => 79,
                    'quantity' => 1
                ],
                [
                    'product_id' => 93,
                    'quantity' => 1
                ],
                [
                    'product_id' => 22,
                    'variation_id' => 23,
                    'quantity' => 1
                ]
            ],
            'shipping_lines' => [
                [
                    'method_id' => 'flat_rate',
                    'method_title' => 'Flat Rate',
                    'total' => 30
                ]
            ]
        ],
        [
            'payment_method' => 'bacs',
            'payment_method_title' => 'Direct Bank Transfer',
            'set_paid' => true,
            'billing' => [
                'first_name' => 'John',
                'last_name' => 'Doe',
                'address_1' => '969 Market',
                'address_2' => '',
                'city' => 'San Francisco',
                'state' => 'CA',
                'postcode' => '94103',
                'country' => 'US',
                'email' => 'john.doe@example.com',
                'phone' => '(555) 555-5555'
            ],
            'shipping' => [
                'first_name' => 'John',
                'last_name' => 'Doe',
                'address_1' => '969 Market',
                'address_2' => '',
                'city' => 'San Francisco',
                'state' => 'CA',
                'postcode' => '94103',
                'country' => 'US'
            ],
            'line_items' => [
                [
                    'product_id' => 22,
                    'variation_id' => 23,
                    'quantity' => 1
                ],
                [
                    'product_id' => 22,
                    'variation_id' => 24,
                    'quantity' => 1
                ]
            ],
            'shipping_lines' => [
                [
                    'method_id' => 'flat_rate',
                    'method_title' => 'Flat Rate',
                    'total' => 20
                ]
            ]
        ]
    ],
    'update' => [
        [
            'id' => 727,
            'shipping_methods' => 'Local Delivery'
        ]
    ],
    'delete' => [
        723
    ]
];
$batch = Order::batch($data);

                    

Order Notes

Properties

See all order note properties from here https://woocommerce.github.io/woocommerce-rest-api-docs/#order-note-properties

Create note

Import use Codexshaper\WooCommerce\Facades\Note; or simply use Note; To avoid conflict with other class use full qualified classes (with namespace).

<?php 

$order_id = 173;
$data = [
    'note' => 'Order ok!!!'
];

$note = Note::create($order_id, $data);

OR

$note = Order::createNote($order_id, $data);
              

Retrieve a note

Import use Codexshaper\WooCommerce\Facades\Note; or simply use Note; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$order_id = 173;
$note_id = 1;

$note = Note::find($order_id, $note_id);
OR
$note = Order::note($order_id, $note_id);
                        

Retrieve all notes

Import use Codexshaper\WooCommerce\Facades\Note; or simply use Note; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$order_id = 173;

$notes = Note::all($order_id);
OR
$notes = Order::notes($order_id);
                    

Delete a order note

Import use Codexshaper\WooCommerce\Facades\Note; or simply use Note; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$order_id = 173;
$note_id = 1;
$options = ['force' => true]; // Set force option true for delete permanently. Default value false

$note = Note::delete($order_id, $note_id, $options);
OR
$note = Order::deleteNote($order_id, $note_id, $options);
                    

Order refund

Properties

See all order refund properties from here https://woocommerce.github.io/woocommerce-rest-api-docs/#order-refund-properties

Create refund

Import use Codexshaper\WooCommerce\Facades\Refund; or simply use Refund; To avoid conflict with other class use full qualified classes (with namespace).

<?php 

$order_id = 173;
$data = [
    'amount' => '10'
];

$refund = Refund::create($order_id, $data);

OR

$refund = Order::createRefund($order_id, $data);
              

Retrieve a refund

Import use Codexshaper\WooCommerce\Facades\Refund; or simply use Refund; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$order_id = 173;
$refund_id = 1;

$refund = Refund::find($order_id, $refund_id);
OR
$refund = Order::refund($order_id, $refund_id);
                        

Retrieve all refunds

Import use Codexshaper\WooCommerce\Facades\Refund; or simply use Refund; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$order_id = 173;

$refunds = Refund::all($order_id);
OR
$refunds = Order::refunds($order_id);
                    

Delete a order refund

Import use Codexshaper\WooCommerce\Facades\Refund; or simply use Refund; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$order_id = 173;
$refund_id = 1;
$options = ['force' => true]; // Set force option true for delete permanently. Default value false

$refund = Refund::delete($order_id, $refund_id, $options);
OR
$refund = Order::deleteRefund($order_id, $refund_id, $options);
                    

Reports

Retrieve all report

Import use Codexshaper\WooCommerce\Facades\Report; or simply use Report; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$orders = Report::all();
                    

Retrieve sales report

Import use Codexshaper\WooCommerce\Facades\Report; or simply use Report; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$orders = Report::sales();
                    

Retrieve top sellers report

Import use Codexshaper\WooCommerce\Facades\Report; or simply use Report; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$orders = Report::topSellers();
                    

Retrieve coupons totals

Import use Codexshaper\WooCommerce\Facades\Report; or simply use Report; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$orders = Report::coupons();
                    

Retrieve customers totals

Import use Codexshaper\WooCommerce\Facades\Report; or simply use Report; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$orders = Report::customers();
                    

Retrieve orders totals

Import use Codexshaper\WooCommerce\Facades\Report; or simply use Report; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$orders = Report::orders();
                    

Retrieve products totals

Import use Codexshaper\WooCommerce\Facades\Report; or simply use Report; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$orders = Report::products();
                    

Retrieve reviews totals

Import use Codexshaper\WooCommerce\Facades\Report; or simply use Report; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$orders = Report::reviews();
                    

Webhook

Properties

See all webhook properties from here https://woocommerce.github.io/woocommerce-rest-api-docs/#webhook-properties

Create a webhook

Import use Codexshaper\WooCommerce\Facades\Webhook; or simply use Webhook; To avoid conflict with other class use full qualified classes (with namespace).

<?php 

$data = [
    'name' => 'Order updated',
    'topic' => 'order.updated',
    'delivery_url' => 'http://requestb.in/1g0sxmo1'
];

$webhook = Webhook::create($data);
            

Retrieve a webhook

Import use Codexshaper\WooCommerce\Facades\Webhook; or simply use Webhook; To avoid conflict with other class use full qualified classes (with namespace).

<?php
$hook_id = 1;
$webhook = Webhook::find($hook_id);
                        

Retrieve all products

Import use Codexshaper\WooCommerce\Facades\Webhook; or simply use Webhook; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$webhooks = Webhook::all();
                    

Update a webhook

Import use Codexshaper\WooCommerce\Facades\Webhook; or simply use Webhook; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$hook_id = 40;
$data = [
    'status' => 'paused'
];

$webhook = Webhook::update($hook_id, $data);
                    

Delete a webhook

Import use Codexshaper\WooCommerce\Facades\Webhook; or simply use Webhook; To avoid conflict with other class use full qualified classes (with namespace).

<?php

$hook_id = 40;
$options = ['force' => true]; // Set force option true for delete permanently. Default value false

$webhook = Webhook::delete($hook_id, $options);
                    

Batch update webhooks

Import use Codexshaper\WooCommerce\Facades\Webhook; or simply use Webhook; To avoid conflict with other class use full qualified classes (with namespace).
Create, Update and Delete in one command

<?php

$data = [
    'create' => [
        [
            'name' => 'Round toe',
            'topic' => 'coupon.created',
            'delivery_url' => 'http://requestb.in/1g0sxmo1'
        ],
        [
            'name' => 'Customer deleted',
            'topic' => 'customer.deleted',
            'delivery_url' => 'http://requestb.in/1g0sxmo1'
        ]
    ],
    'update' => [
        'status' => 'paused'
    ],
    'delete' => [
        143
    ]
];

$batch = Webhook::batch($data);