Need help with WooCommerce.NET?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

XiaoFaye
296 Stars 172 Forks MIT License 161 Commits 131 Opened issues

Description

A .NET Wrapper for WooCommerce/WordPress REST API

Services available

!
?

Need anything else?

Contributors list

WooCommerce.NET

A Brief Intro

WooCommerce.NET is a .NET library for calling WooCommerce/WordPress REST API with OAuth/JWT in .NET applications.

NuGet

If this project has been helpful for you and you want to support it, please consider Buying me a coffee:coffee:

Usage (WooCommerce REST API)

Click to expand/collapse details...
using WooCommerceNET.WooCommerce.v3;
using WooCommerceNET.WooCommerce.v3.Extension;

RestAPI rest = new RestAPI("http://www.yourstore.co.nz/wp-json/wc/v3/", "<woocommerce key>", "<woocommerce secret wcobject wc="new" all products var wc.product.getall new product p="new" name="test product 8" title="test product 8" description="test product 8" price="8.0M" await wc.product.add with values wc.product.update null wc.product.updatewithnull weight="" date_on_sale_from="" date_on_sale_to="" wc.product.delete parameters dictionary string>() {
                { "include", "10, 11, 12, 13, 14, 15" },
                { "per_page", "15" } });


//Batch add/update/delete
CustomerBatch cb = new CustomerBatch();

List<customer> create = new List<customer>();
create.Add(new Customer()
{
    first_name = "first",
    last_name = "last",
    email = "[email protected]",
    username = "firstnlast",
    password = "12345"
});

List<customer> update = new List<customer>();
update.Add(new Customer()
{
    id = 4,
    last_name = "xu2"
});

List<int> delete = new List<int>() { 8 };
cb.create = create;
cb.update = update;
cb.delete = delete;

var c = await wc.Customer.UpdateRange(cb);

Usage (WordPress REST API - JWT/OAuth Authentication)

Click to expand/collapse details...

//using JWT
RestAPI rest = new RestAPI("http://www.yourstore.co.nz/wp-json/jwt-auth/v1/token", "<username>", "<password>");

//using OAuth
RestAPI rest = new RestAPI("http://www.yourstore.co.nz/wp-json/wp/v2/", "<client_key>", "<client_secret>");
rest.oauth_token = "<oauth_token>";
rest.oauth_token_secret = "<oauth_token_secret>";

WPObject wp = new WPObject(rest);

//Get all posts
var posts = await wp.Post.GetAll();

//Add a post
var p = new Posts()
{
    title = "abc",
    content = "<h1>abc</h1>"
};

await wp.Post.Add(p);

//Update post with new values
await wp.Post.Update(123, new { title = "new post" });

//Delete a post
await wp.Post.Delete(123);

//Upload an image
await wp.Media.Add("imagename.jpg", @"C:\path\to\image\file.jpg");

//Create a new user
await wp.Users.Add(new Users()
{
    first_name = "test",
    last_name = "test",
    name = "test",
    username = "test123",
    email = "[email protected]",
    password = "[email protected]"
});

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.