Categorygithub.com/dinistavares/go-woocommerce-api
modulepackage
0.1.3
Repository: https://github.com/dinistavares/go-woocommerce-api.git
Documentation: pkg.go.dev

# README

go-woocommerce-api

A Woocommerce API Golang Wrapper for the Woocommerce Rest API (v3)

Install

$ go get github.com/dinistavares/go-woocommerce-api

Usage

Create a new API client and authenticate with your REST API keys. You should specify the URL protocol by prefixing your domain name with https:// or http://. Follow the Woocommerce documentation to create your API keys through the Wordpress admin interface or using the authentication endpoint.

import (
  "github.com/dinistavares/go-woocommerce-api"
)

func main(){
  shopURL := "https://example.com"
  key := "ck_xxxxxxx"
  secret := "cs_xxxxxxx"

  client, err := woocommerce.New(shopURL)

  if err != nil {
    // handle error

    return
  }

  client.Authenticate(key, secret)
}

The API routes are broken down into services, the supported services are:

  • Coupons (Create, Get, List, Update, Delete, Batch)
  • Customers (Create, Get, List, Update, Delete, Batch, GetDownloads)
  • Orders (Create, Get, List, Update, Delete, Batch)
  • OrderNotes (Create, Get, List, Delete)
  • Refunds (Create, Get, List, Delete)
  • Products (Create, Get, List, Update, Delete, Batch)
  • Webhooks (Create, Get, List, Update, Delete, Batch)

List Orders by customer ID and page number.

func (client *woocommerce.Client) listOrders() {
  customerID := 3
  pageNumber := 1

  opts := woocommerce.ListOrdersParams{
    Customer: customerID,
    Page: pageNumber,
  }

  orders, resp, err := client.Orders.List(opts)

  if err != nil {
    // Handle errors

    return
  }

  // Pagination headers.
  totalPages := resp.Header.Get("X-Wp-Totalpages")
  totalItems := resp.Header.Get("X-Wp-Total")

  // ....

}

# Functions

No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Coupon object.
No description provided by the author
Customer object.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Order object.
OrderNote object.
No description provided by the author
Product object.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Refund object.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

Coupon service.
Customer service.
Order Notes service.
Orders service.
Product service.
Refunds service.
Webhooks service.