Skip to content

samarthagarwal/woocommerce_dart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

a7cc458 · May 20, 2021

History

22 Commits
Sep 26, 2018
Apr 21, 2020
May 3, 2019
May 20, 2021
Apr 21, 2020
May 20, 2021
Sep 26, 2018
May 20, 2021
May 20, 2021
May 20, 2021
Oct 1, 2018
May 20, 2021
May 20, 2021
Apr 27, 2020

Repository files navigation

WooCommerce SDK for Dart

A dart package to interact with the WooCommerce API (now with null-safety). It uses OAuth1.0a behind the scenes to generate the signature and URL string for http based websites. It then makes calls and returns the data back to the calling function asynchronously.

Example code and preview

Examples

GET request (Fetch products)

Future getProducts() async {
  // Initialize the API
  WooCommerceAPI wooCommerceAPI = WooCommerceAPI(
      url: "https://www.yourwebsite.com",
      consumerKey: "ck_your_consumer_key",
      consumerSecret: "cs_your_consumer_secret");

  // Get data using the "products" endpoint
  var products = await wooCommerceAPI.getAsync("products");
  return products;
}

You can find a full example here

POST request (Create a customer)

Future createCustomer() async {
  try {
    var response = await wooCommerceAPI.postAsync(
      "customers",
      {
        "email": 's@c.com',
        "password": "123",
        "billing": {
          "first_name": "Samarth",
        }
      },
    );
    print(response); // JSON Object with response
  } catch (e) {
    print(e);
  }
}

Report any issues if you face any or drop me an email at samarthagarwal@live.com