<?php
WOOCOMMERCE_STORE_URL=YOUR_WEBSITE_URL
WOOCOMMERCE_CONSUMER_KEY=API_CONSUMER_KEY
WOOCOMMERCE_CONSUMER_SECRET=API_CONSUMER_SECRET
<?php
$data = [
'code' => '10off',
'discount_type' => 'percent',
'amount' => '10',
'individual_use' => true,
'exclude_sale_items' => true,
'minimum_amount' => '100.00'
];
$coupon = Coupon::create($data);
<?php
$coupon_id = 1;
$coupon = Coupon::find($coupon_id);
<?php
$coupons = Coupon::all();
<?php
$coupon_id = 2;
$data = [
'amount' => '5'
];
$custmer = Coupon::update($coupon_id, $data);
<?php
$coupon_id = 40;
$options = ['force' => true]; // Set force option true for delete permanently. Default value false
$coupon = Coupon::delete($coupon_id, $options);
<?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);
<?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);
<?php
$customer_id = 1;
$customer = Customer::find($customer_id);
<?php
$customers = Customer::all();
<?php
$customer_id = 2;
$data = [
'first_name' => 'James',
'billing' => [
'first_name' => 'James'
],
'shipping' => [
'first_name' => 'James'
]
];
$custmer = Customer::update($customer_id, $data);
<?php
$customer_id = 40;
$options = ['force' => true]; // Set force option true for delete permanently. Default value false
$customer = Customer::delete($customer_id, $options);
<?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);
<?php
$customer_id = 40;
$downloads = Customer::downloads($customer_id);
<?php
$name = 'bacs';
$paymentGateway = PaymentGateway::find($name);
<?php
$paymentGateways = PaymentGateway::all();
<?php
$name = 'bacs';
$data = [
'enabled' => true
];
$paymentGateway = PaymentGateway::update($name, $data);
<?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);
<?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);
<?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();
<?php
$product_id = 1;
$product = Product::find($product_id);
<?php
$products = Product::all();
<?php
$product_id = 40;
$data = [
'regular_price' => '50',
'sale_price' => '25', // 50% off
];
$product = Product::update($product_id, $data);
<?php
$product_id = 40;
$options = ['force' => true]; // Set force option true for delete permanently. Default value false
$product = Product::delete($product_id, $options);
<?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);
<?php
$product_id = 70;
$data = [
'regular_price' => '9.00',
'image' => [
'id' => 423
],
'attributes' => [
[
'id' => 9,
'option' => 'Black'
]
]
];
$variation = Variation::create($product_id, $data);
<?php
$product_id = 70;
$variation_id = 1;
$variation = Variation::find($product_id, $variation_id);
<?php
$product_id = 70;
$variations = Variation::all($product_id);
<?php
$product_id = 70;
$variation_id = 173;
$data = [
'regular_price' => '10.00'
];
$variation = Variation::update($product_id, $variation_id, $data);
<?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);
<?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);
<?php
$data = [
'name' => 'Color',
'slug' => 'pa_color',
'type' => 'select',
'order_by' => 'menu_order',
'has_archives' => true
];
$attribute = Attribute::create($data);
<?php
$attribute_id = 1;
$attribute = Attribute::find($attribute_id);
<?php
$attributes = Attribute::all();
<?php
$attribute_id = 173;
$data = [
'order_by' => 'name'
];
$attribute = Attribute::update($attribute_id, $data);
<?php
$attribute_id = 173;
$options = ['force' => true]; // Set force option true for delete permanently. Default value false
$attribute = Attribute::delete($attribute_id, $options);
<?php
$data = [
'create' => [
[
'name' => 'Brand'
],
[
'name' => 'Publisher'
]
],
'update' => [
[
'id' => 2,
'order_by' => 'name'
]
],
'delete' => [
1
]
];
$batch = Attribute::batch($data);
<?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);
<?php
$attribute_id = 1;
$term_id = 5;
$term = Term::find($attribute_id, $term_id);
OR
$term = Attribute::getTerm($attribute_id, $term_id);
<?php
$attribute_id = 1;
$terms = Term::all($attribute_id);
OR
$terms = Attribute::getTerms($attribute_id);
<?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);
<?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);
<?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);
<?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);
<?php
$category_id = 1;
$category = Category::find($category_id);
<?php
$categorys = Category::all();
<?php
$category_id = 173;
$data = [
'description' => 'All kinds of clothes.'
];
$category = Category::update($category_id, $data);
<?php
$category_id = 173;
$options = ['force' => true]; // Set force option true for delete permanently. Default value false
$category = Category::delete($category_id, $options);
<?php
$data = [
'create' => [
[
'name' => 'Albums'
],
[
'name' => 'Clothing'
]
],
'update' => [
[
'id' => 10,
'description' => 'Nice hoodies'
]
],
'delete' => [
11,
12
]
];
$batch = Category::batch($data);
<?php
$data = [
'name' => 'Leather Shoes'
];
$tag = Tag::create($data);
<?php
$tag_id = 1;
$tag = Tag::find($tag_id);
<?php
$tag_id = 173;
$data = [
'description': 'Genuine leather.'
];
$tag = Tag::update($tag_id, $data);
<?php
$tag_id = 173;
$options = [
'force' => true // Set force option true for delete permanently. Default value false
];
$tag = Tag::delete($tag_id, $options);
<?php
$data = [
'create' => [
[
'name' => 'Round toe'
],
[
'name' => 'Flat'
]
],
'update' => [
[
'id' => 34,
'description' => 'Genuine leather.'
]
],
'delete' => [
35
]
];
$batch = Tag::batch($data);
<?php
$data = [
'product_id' => 22,
'review' => 'Nice album!',
'reviewer' => 'John Doe',
'reviewer_email' => 'john.doe@example.com',
'rating' => 5
];
$review = Review::create($data);
<?php
$review_id = 1;
$review = Review::find($review_id);
<?php
$reviews = Review::all();
<?php
$review_id = 173;
$data = [
'rating': 5
];
$review = Review::update($review_id, $data);
<?php
$review_id = 173;
$options = [
'force' => true // Set force option true for delete permanently. Default value false
];
$review = Review::delete($review_id, $options);
<?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);
<?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);
<?php
$order_id = 1;
$order = Order::find($order_id);
<?php
$orders = Order::all();
<?php
$order_id = 173;
$data = [
'status' => 'completed',
];
$order = Order::update($order_id, $data);
<?php
$order_id = 173;
$options = ['force' => true]; // Set force option true for delete permanently. Default value false
$order = Order::delete($order_id, $options);
<?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);
<?php
$order_id = 173;
$data = [
'note' => 'Order ok!!!'
];
$note = Note::create($order_id, $data);
OR
$note = Order::createNote($order_id, $data);
<?php
$order_id = 173;
$note_id = 1;
$note = Note::find($order_id, $note_id);
OR
$note = Order::note($order_id, $note_id);
<?php
$order_id = 173;
$notes = Note::all($order_id);
OR
$notes = Order::notes($order_id);
<?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);
<?php
$order_id = 173;
$data = [
'amount' => '10'
];
$refund = Refund::create($order_id, $data);
OR
$refund = Order::createRefund($order_id, $data);
<?php
$order_id = 173;
$refund_id = 1;
$refund = Refund::find($order_id, $refund_id);
OR
$refund = Order::refund($order_id, $refund_id);
<?php
$order_id = 173;
$refunds = Refund::all($order_id);
OR
$refunds = Order::refunds($order_id);
<?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);
<?php
$orders = Report::all();
<?php
$orders = Report::sales();
<?php
$orders = Report::topSellers();
<?php
$orders = Report::coupons();
<?php
$orders = Report::customers();
<?php
$orders = Report::orders();
<?php
$orders = Report::products();
<?php
$orders = Report::reviews();
<?php
$data = [
'name' => 'Order updated',
'topic' => 'order.updated',
'delivery_url' => 'http://requestb.in/1g0sxmo1'
];
$webhook = Webhook::create($data);
<?php
$hook_id = 1;
$webhook = Webhook::find($hook_id);
<?php
$webhooks = Webhook::all();
<?php
$hook_id = 40;
$data = [
'status' => 'paused'
];
$webhook = Webhook::update($hook_id, $data);
<?php
$hook_id = 40;
$options = ['force' => true]; // Set force option true for delete permanently. Default value false
$webhook = Webhook::delete($hook_id, $options);
<?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);