gowoocommerce

package module
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2021 License: MIT Imports: 4 Imported by: 0

README

gowoocommerce

GitHub go.mod Go version of a Go module Go Go Report Card Go Doc Lines of code

With this library it is possible to call the Woocommerce v3 api with functions. We extend this library according to our needs. We are looking forward to more hardworking hands.

Install

go get github.com/jjideenschmiede/gowoocommerce

How to use?

Products

If you want to read out products, then you can do this via the following function. It is important that the page number is stored in the function. There are always 100 products loaded per page. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Get all products from the page
products, err := gowoocommerce.Products(1, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(products)
}
Create a product

If you want to create a new product, you can do it as follows. For this, some data is mandatory. The function also returns the error codes from WooCommerce.

The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Define product body
body := gowoocommerce.ProductsBody{
    Name:              "J&J Interface V2",
    Slug:              "jj-interface",
    Type:              "simple",
    Status:            "publish",
    Featured:          false,
    CatalogVisibility: "visible",
    Description:       "<h1>J&J Interface</h1><p>Das ist eine Beschreibung.</p>",
    ShortDescription:  "Unsere Schnittstelle zwischen Warenwirtschaft und Online Shop.",
    Sku:               "",
    Price:             "2800",
    RegularPrice:      "3000",
    SalePrice:         "",
    DateOnSaleFrom:    nil,
    DateOnSaleFromGmt: nil,
    DateOnSaleTo:      nil,
    DateOnSaleToGmt:   nil,
    OnSale:            false,
    Purchasable:       false,
    TotalSales:        0,
    Virtual:           false,
    Downloadable:      false,
    Downloads:         nil,
    DownloadLimit:     -1,
    DownloadExpiry:    -1,
    ExternalUrl:       "",
    ButtonText:        "",
    TaxStatus:         "taxable",
    TaxClass:          "",
    ManageStock:       true,
    StockQuantity:     120,
    Backorders:        "no",
    BackordersAllowed: false,
    Backordered:       false,
    LowStockAmount:    nil,
    SoldIndividually:  false,
    Weight:            "",
    Dimensions:        gowoocommerce.ProductsBodyDimensions{},
    ShippingRequired:  false,
    ShippingTaxable:   false,
    ShippingClass:     "",
    ShippingClassId:   0,
    ReviewsAllowed:    false,
    AverageRating:     "",
    RatingCount:       0,
    UpsellIds:         nil,
    CrossSellIds:      nil,
    ParentId:          0,
    PurchaseNote:      "",
    Categories:        []gowoocommerce.ProductsBodyCategories{},
    Tags:              nil,
    Images:            []gowoocommerce.ProductsBodyImages{},
    Attributes:        nil,
    DefaultAttributes: nil,
    Variations:        nil,
    GroupedProducts:   nil,
    MenuOrder:         0,
    RelatedIds:        nil,
    MetaData:          nil,
    StockStatus:       "instock",
}

// Add an image
body.Images = append(body.Images, gowoocommerce.ProductsBodyImages{
    Src:  "https://shop.jj-ideenschmiede.de/media/3e/81/e8/1621082068/jj-interface-shop.png",
    Name: "J&J Interface",
    Alt:  "jj-interface",
})

// Create new product
products, err := gowoocommerce.CreateProduct(body, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(products)
}
Update a product

If you want to update a product, it works like creating a product. With the difference that you need the ID of the product. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
BaseUrl:        "",
ConsumerKey:    "",
ConsumerSecret: "",
}

// Define product body
body := gowoocommerce.ProductsBody{
    Name:              "J&J Interface",
    Slug:              "jj-interface",
    Type:              "simple",
    Status:            "publish",
    Featured:          false,
    CatalogVisibility: "visible",
    Description:       "<h1>J&J Interface</h1><p>Das ist eine Beschreibung.</p>",
    ShortDescription:  "Unsere Schnittstelle zwischen Warenwirtschaft und Online Shop.",
    Sku:               "",
    Price:             "2800",
    RegularPrice:      "3000",
    SalePrice:         "",
    DateOnSaleFrom:    nil,
    DateOnSaleFromGmt: nil,
    DateOnSaleTo:      nil,
    DateOnSaleToGmt:   nil,
    OnSale:            false,
    Purchasable:       false,
    TotalSales:        0,
    Virtual:           false,
    Downloadable:      false,
    Downloads:         nil,
    DownloadLimit:     -1,
    DownloadExpiry:    -1,
    ExternalUrl:       "",
    ButtonText:        "",
    TaxStatus:         "taxable",
    TaxClass:          "",
    ManageStock:       true,
    StockQuantity:     120,
    Backorders:        "no",
    BackordersAllowed: false,
    Backordered:       false,
    LowStockAmount:    nil,
    SoldIndividually:  false,
    Weight:            "",
    Dimensions:        gowoocommerce.ProductsBodyDimensions{},
    ShippingRequired:  false,
    ShippingTaxable:   false,
    ShippingClass:     "",
    ShippingClassId:   0,
    ReviewsAllowed:    false,
    AverageRating:     "",
    RatingCount:       0,
    UpsellIds:         nil,
    CrossSellIds:      nil,
    ParentId:          0,
    PurchaseNote:      "",
    Categories:        []gowoocommerce.ProductsBodyCategories{},
    Tags:              nil,
    Images:            []gowoocommerce.ProductsBodyImages{},
    Attributes:        nil,
    DefaultAttributes: nil,
    Variations:        nil,
    GroupedProducts:   nil,
    MenuOrder:         0,
    RelatedIds:        nil,
    MetaData:          nil,
    StockStatus:       "instock",
}

// Add an image
body.Images = append(body.Images, gowoocommerce.ProductsBodyImages{
    Src:  "https://shop.jj-ideenschmiede.de/media/3e/81/e8/1621082068/jj-interface-shop.png",
    Name: "J&J Interface",
    Alt:  "jj-interface",
})

// Create new product
products, err := gowoocommerce.UpdateProduct(22, body, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(products)
}
Delete a product

If you want to remove a product, you need the ID of the product. This must be stored with the function. Also the value force must be answered with true or false. If this is true, then the product is permanently removed. If the value is answered with false, then the product ends up in the recycle bin for the time being.

The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Delete a product
products, err := DeleteProduct(17, false, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(products)
}
List all product tags

If you want to display all keywords, you can use the following function. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Get all product tags
productTags, err := gowoocommerce.ProductTags(r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(productTags)
}
Retrieve a product tag

If you want to read out a product tag, you can do this using the following function. Only an Id is needed for this. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Get a product tags
productTag, err := gowoocommerce.ProductTag(187, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(productTag)
}
Create a product tag

If you want to create a new keyword, you can do this using the following function. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Create product tag body
body := gowoocommerce.ProductTagsBody{
    Name:        "Schuhe",
    Slug:        "schuhe",
    Description: "Das ist die Beschreibung der Schuhe.",
}

// Create a new product tag
productTag, err := gowoocommerce.CreateProductTag(body, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(productTag)
}
Update a product tag

If you want to update a keyword, you need the id of the product keyword. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Create product tag body
body := gowoocommerce.ProductTagsBody{
    Name:        "Schuhe",
    Slug:        "schuhe",
    Description: "Das ist die Beschreibung der Schuhe.",
}

// Update a product tag
productTag, err := gowoocommerce.UpdateProductTag(187, body, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(productTag)
}
Delete a product tag

If you want to delete a product keyword, then the id is needed a boolean whether to remove the keyword irrevocably or not. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Delete date a product tag
productTag, err := gowoocommerce.DeleteProductTag(159, true, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(productTag)
}
Product attributes

With this function you can read out all product attributes. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Read all product attributes
productAttributes, err := gowoocommerce.ProductAttributes(r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(productAttributes)
}
Create a product attribute

If you want to add an attribute, you can do it with the following function. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Define attributes body
body := gowoocommerce.ProductAttributesBody{
    Name:        "Schuhgröße",
    Slug:        "schuhgroesse",
    Type:        "select",
    OrderBy:     "menu_order",
    HasArchives: true,
}

// Create new product
productAttributes, err := gowoocommerce.CreateProductAttributes(body, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(productAttributes)
}
Update a product attribute

If an attribute is to be updated, this is done with the following function. It is important that the ID of the attribute is specified. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Define attributes body
body := gowoocommerce.ProductAttributesBody{
    Name:        "Schuhgröße V2",
    Slug:        "schuhgroesse",
    Type:        "select",
    OrderBy:     "menu_order",
    HasArchives: true,
}

// Create new product
productAttributes, err := gowoocommerce.UpdateProductAttributes(1, body, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(productAttributes)
}
Delete a product attribute

If you want to remove an attribute, you can do so with this function. The ID of the attribute to be deleted is required. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Delete a product attributes
productAttributes, err := gowoocommerce.DeleteProductAttributes(1, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(productAttributes)
}
List all attribute terms

If you want to read the attribute terms, you can do it as follows. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Read all attribute terms
productAttributeTerms, err := gowoocommerce.ProductAttributeTerms(3, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(productAttributeTerms)
}
Create an attribute term

If you want to assign a new term to an attribute, you can do this as follows. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Define body
body := gowoocommerce.ProductAttributeTermBody{
    Name:        "XXL",
    Slug:        "xxl",
    Description: "Ich bin eine Beschreibung.",
    MenuOrder:   0,
}

// Create a new term
productAttributeTerms, err := gowoocommerce.CreateProductAttributeTerms(3, body, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(productAttributeTerms)
}
Update an attribute term

If you want to update a term, you can do this as follows. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Define body
body := gowoocommerce.ProductAttributeTermBody{
    Name:        "XXS",
    Slug:        "xxs",
    Description: "Ich bin eine neue Beschreibung.",
    MenuOrder:   0,
}

// Update a term
productAttributeTerms, err := gowoocommerce.UpdateProductAttributeTerms(3, 23, body, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(productAttributeTerms)
}
Delete an attribute term

If you want to remove a term, then you need the ID of the attribute and the ID of the term. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Delete a product attribute term
productAttributeTerms, err := gowoocommerce.DeleteProductAttributeTerms(3, 20, true, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(productAttributeTerms)
}
Product variations

If you want to read out all variants for a product, you can do this as follows. The ID of the variant product is required. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Read all product variations
productVariations, err := gowoocommerce.ProductVariations(33, 1, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(productVariations)
}
Create a product variant

If you want to create a new variant, you can do so using this function. Thereby some values are needed. The library returns these as values if they should occur. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Define body
body := gowoocommerce.ProductVariationsBody{
    Description:       "Our Version for Shopify.",
    Permalink:         "",
    Sku:               "",
    Price:             "255",
    RegularPrice:      "",
    SalePrice:         "215",
    DateOnSaleFrom:    nil,
    DateOnSaleFromGmt: nil,
    DateOnSaleTo:      nil,
    DateOnSaleToGmt:   nil,
    OnSale:            false,
    Status:            "publish",
    Purchasable:       false,
    Virtual:           false,
    Downloadable:      false,
    Downloads:         nil,
    DownloadLimit:     -1,
    DownloadExpiry:    -1,
    TaxStatus:         "taxable",
    TaxClass:          "",
    ManageStock:       false,
    StockQuantity:     nil,
    StockStatus:       "instock",
    Backorders:        "no",
    BackordersAllowed: false,
    Backordered:       false,
    Weight:            "",
    Dimensions:        gowoocommerce.ProductVariationsBodyDimensions{},
    ShippingClass:     "",
    ShippingClassId:   0,
    Image: gowoocommerce.ProductVariationsBodyImages{
        Src:  "https://shop.jj-ideenschmiede.de/thumbnail/3e/81/e8/1621082068/jj-interface-shop_1920x1920.png",
        Name: "J&J Interface",
        Alt:  "J&J Interface",
    },
    Attributes: []gowoocommerce.ProductVariationsBodyAttributes{},
    MenuOrder:  0,
    MetaData:   nil,
}

// Add attribute
body.Attributes = append(body.Attributes, gowoocommerce.ProductVariationsBodyAttributes{
    Name:   "Shopsoftware",
    Option: "WooCommerce",
})

// Create a new variant to a product
productVariations, err := gowoocommerce.CreateProductVariations(33, body, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(productVariations)
}
Update a product variant

If you want to update a variant, you can do this as follows. Everything is the same as when you create a variant. Only the ID of the variant must be stored. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Define body
body := gowoocommerce.ProductVariationsBody{
    Description:       "Our Version for Shopify.",
    Permalink:         "",
    Sku:               "",
    Price:             "255",
    RegularPrice:      "",
    SalePrice:         "215",
    DateOnSaleFrom:    nil,
    DateOnSaleFromGmt: nil,
    DateOnSaleTo:      nil,
    DateOnSaleToGmt:   nil,
    OnSale:            false,
    Status:            "publish",
    Purchasable:       false,
    Virtual:           false,
    Downloadable:      false,
    Downloads:         nil,
    DownloadLimit:     -1,
    DownloadExpiry:    -1,
    TaxStatus:         "taxable",
    TaxClass:          "",
    ManageStock:       false,
    StockQuantity:     nil,
    StockStatus:       "instock",
    Backorders:        "no",
    BackordersAllowed: false,
    Backordered:       false,
    Weight:            "",
    Dimensions:        gowoocommerce.ProductVariationsBodyDimensions{},
    ShippingClass:     "",
    ShippingClassId:   0,
    Image: gowoocommerce.ProductVariationsBodyImages{
        Src:  "https://shop.jj-ideenschmiede.de/thumbnail/3e/81/e8/1621082068/jj-interface-shop_1920x1920.png",
        Name: "J&J Interface",
        Alt:  "J&J Interface",
    },
    Attributes: []gowoocommerce.ProductVariationsBodyAttributes{},
    MenuOrder:  0,
    MetaData:   nil,
}

// Add attribute
body.Attributes = append(body.Attributes, gowoocommerce.ProductVariationsBodyAttributes{
    Name:   "Shopsoftware",
    Option: "WooCommerce",
})

// Update a variant to a product
productVariations, err := gowoocommerce.UpdateProductVariations(33, 45, body, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(productVariations)
}
Delete a product variant

If you want to remove a variant, you can do this with the following function. This requires a productID and a variantID. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Remove a variant from a product
productVariations, err := gowoocommerce.DeleteProductVariations(33, 37, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(productVariations)
}
Product categories

With the following function you can read out the stored categories. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Get all product categories
categories, err := gowoocommerce.ProductCategories(r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(categories)
}
Add product category

With the following function you can add the new categories. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Define body data
body := gowoocommerce.ProductCategory{
    Name:        "",
    Parent:      0,
    Description: "",
    Display:     "",
    MenuOrder:   0,
    Image: gowoocommerce.ProductCategoryImage{
        Src: "",
    },
}

// Create a new product category
category, err := gowoocommerce.AddProductCategory(body, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(category)
}
Update a product category

If you want to renew an existing product category, then this actually works like creating a new category. In the function, however, the ID of the category must be specified. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}


// Define body data
body := gowoocommerce.ProductCategory{
    Name:        "",
    Parent:      0,
    Description: "",
    Display:     "",
    MenuOrder:   0,
    Image: gowoocommerce.ProductCategoryImage{
        Src: "",
    },
}

// Update a product category
category, err := gowoocommerce.UpdateProductCategory(0, body, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(category)
}
Delete a product category

To delete a category, only the ID of the category is needed. You can use this function to remove the category. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Remove a product categories
category, err := gowoocommerce.DeleteProductCategory(18, true, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(category)
}
Read all orders

If you want to read out all orders, you can do it page by page using the following function. 100 orders are always read out at once. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Get all orders from the page
orders, err := gowoocommerce.Orders(1, "2021-09-13T11:13:42", r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(orders)
}
Update a order

If you want to update an order, this is currently possible via this function. Since only the status is stored in the documentation for the time being, we have currently only stored the status. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Define order status update
body := gowoocommerce.UpdateOrderBody{
    Id:     330,
    Status: "completed",
}

// Update the status of an order
updateOrderStatus, err := gowoocommerce.UpdateOrder(body, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(updateOrderStatus)
}
Create a new order note

If you want to create a note for an order, you can do this using the following function. You can decide whether it is a note for the customer or an internal note. In this example the note is also for the customer. The description of the API endpoint can be found here.

// Define the request
r := gowoocommerce.Request{
    BaseUrl:        "",
    ConsumerKey:    "",
    ConsumerSecret: "",
}

// Define order status update
body := gowoocommerce.OrderNotesBody{
    Note:         "Trackingnummer",
    CustomerNote: true,
    AddedByUser:  false,
}

// Update the status of an order
createOrderNote, err := gowoocommerce.CreateOrderNote(12, body, r)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(createOrderNote)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Path, Method string
	Body         []byte
}

Config is to define config data

func (*Config) Send

func (c *Config) Send(r Request) (*http.Response, error)

Send is to send a new request

type OrderNotesBody added in v1.2.9

type OrderNotesBody struct {
	Note         string `json:"note"`
	CustomerNote bool   `json:"customer_note"`
	AddedByUser  bool   `json:"added_by_user"`
}

OrderNotesBody is to structure the data

type OrderNotesReturn added in v1.2.9

type OrderNotesReturn struct {
	Id             int    `json:"id"`
	Author         string `json:"author"`
	DateCreated    string `json:"date_created"`
	DateCreatedGmt string `json:"date_created_gmt"`
	Note           string `json:"note"`
	CustomerNote   bool   `json:"customer_note"`
	Links          struct {
		Self []struct {
			Href string `json:"href"`
		} `json:"self"`
		Collection []struct {
			Href string `json:"href"`
		} `json:"collection"`
		Up []struct {
			Href string `json:"href"`
		} `json:"up"`
	} `json:"_links"`
	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
	Data    struct {
		Status int `json:"status,omitempty"`
	} `json:"data,omitempty"`
}

OrderNotesReturn is to decode the json return

func CreateOrderNote added in v1.2.9

func CreateOrderNote(id int, body OrderNotesBody, r Request) (OrderNotesReturn, error)

CreateOrderNote is to create an order note

type OrdersReturn

type OrdersReturn struct {
	Id               int    `json:"id"`
	ParentId         int    `json:"parent_id"`
	Status           string `json:"status"`
	Currency         string `json:"currency"`
	Version          string `json:"version"`
	PricesIncludeTax bool   `json:"prices_include_tax"`
	DateCreated      string `json:"date_created"`
	DateModified     string `json:"date_modified"`
	DiscountTotal    string `json:"discount_total"`
	DiscountTax      string `json:"discount_tax"`
	ShippingTotal    string `json:"shipping_total"`
	ShippingTax      string `json:"shipping_tax"`
	CartTax          string `json:"cart_tax"`
	Total            string `json:"total"`
	TotalTax         string `json:"total_tax"`
	CustomerId       int    `json:"customer_id"`
	OrderKey         string `json:"order_key"`
	Billing          struct {
		FirstName string `json:"first_name"`
		LastName  string `json:"last_name"`
		Company   string `json:"company"`
		Address1  string `json:"address_1"`
		Address2  string `json:"address_2"`
		City      string `json:"city"`
		State     string `json:"state"`
		Postcode  string `json:"postcode"`
		Country   string `json:"country"`
		Email     string `json:"email"`
		Phone     string `json:"phone"`
	} `json:"billing"`
	Shipping struct {
		FirstName string `json:"first_name"`
		LastName  string `json:"last_name"`
		Company   string `json:"company"`
		Address1  string `json:"address_1"`
		Address2  string `json:"address_2"`
		City      string `json:"city"`
		State     string `json:"state"`
		Postcode  string `json:"postcode"`
		Country   string `json:"country"`
		Phone     string `json:"phone"`
	} `json:"shipping"`
	PaymentMethod      string        `json:"payment_method"`
	PaymentMethodTitle string        `json:"payment_method_title"`
	TransactionId      string        `json:"transaction_id"`
	CustomerIpAddress  string        `json:"customer_ip_address"`
	CustomerUserAgent  string        `json:"customer_user_agent"`
	CreatedVia         string        `json:"created_via"`
	CustomerNote       string        `json:"customer_note"`
	DateCompleted      interface{}   `json:"date_completed"`
	DatePaid           interface{}   `json:"date_paid"`
	CartHash           string        `json:"cart_hash"`
	Number             string        `json:"number"`
	MetaData           []interface{} `json:"meta_data"`
	LineItems          []struct {
		Id          int    `json:"id"`
		Name        string `json:"name"`
		ProductId   int    `json:"product_id"`
		VariationId int    `json:"variation_id"`
		Quantity    int    `json:"quantity"`
		TaxClass    string `json:"tax_class"`
		Subtotal    string `json:"subtotal"`
		SubtotalTax string `json:"subtotal_tax"`
		Total       string `json:"total"`
		TotalTax    string `json:"total_tax"`
		Taxes       []struct {
			Id       int    `json:"id"`
			Total    string `json:"total"`
			Subtotal string `json:"subtotal"`
		} `json:"taxes"`
		MetaData   []interface{} `json:"meta_data"`
		Sku        string        `json:"sku"`
		Price      float64       `json:"price"`
		ParentName interface{}   `json:"parent_name"`
	} `json:"line_items"`
	TaxLines []struct {
		Id               int           `json:"id"`
		RateCode         string        `json:"rate_code"`
		RateId           int           `json:"rate_id"`
		Label            string        `json:"label"`
		Compound         bool          `json:"compound"`
		TaxTotal         string        `json:"tax_total"`
		ShippingTaxTotal string        `json:"shipping_tax_total"`
		RatePercent      int           `json:"rate_percent"`
		MetaData         []interface{} `json:"meta_data"`
	} `json:"tax_lines"`
	ShippingLines    []interface{} `json:"shipping_lines"`
	FeeLines         []interface{} `json:"fee_lines"`
	CouponLines      []interface{} `json:"coupon_lines"`
	Refunds          []interface{} `json:"refunds"`
	DateCreatedGmt   string        `json:"date_created_gmt"`
	DateModifiedGmt  string        `json:"date_modified_gmt"`
	DateCompletedGmt interface{}   `json:"date_completed_gmt"`
	DatePaidGmt      interface{}   `json:"date_paid_gmt"`
	CurrencySymbol   string        `json:"currency_symbol"`
	Links            struct {
		Self []struct {
			Href string `json:"href"`
		} `json:"self"`
		Collection []struct {
			Href string `json:"href"`
		} `json:"collection"`
	} `json:"_links"`
}

OrdersReturn is to decode the json data

func Orders

func Orders(page int, afterDate string, r Request) ([]OrdersReturn, error)

Orders is to get all orders since id

func UpdateOrder added in v1.2.8

func UpdateOrder(body UpdateOrderBody, r Request) (OrdersReturn, error)

UpdateOrder is to update the status of an order

type ProductAttributeTermBody

type ProductAttributeTermBody struct {
	Name        string `json:"name,omitempty"`
	Slug        string `json:"slug,omitempty"`
	Description string `json:"description,omitempty"`
	MenuOrder   int    `json:"menu_order,omitempty"`
}

ProductAttributeTermBody is to structure the request data

type ProductAttributeTermsReturn

type ProductAttributeTermsReturn struct {
	Id          int    `json:"id"`
	Name        string `json:"name"`
	Slug        string `json:"slug"`
	Description string `json:"description"`
	MenuOrder   int    `json:"menu_order"`
	Count       int    `json:"count"`
	Links       struct {
		Self []struct {
			Href string `json:"href"`
		} `json:"self"`
		Collection []struct {
			Href string `json:"href"`
		} `json:"collection"`
	} `json:"_links"`
}

ProductAttributeTermsReturn is to decode the data

func CreateProductAttributeTerms

func CreateProductAttributeTerms(attributeId int, body ProductAttributeTermBody, r Request) (ProductAttributeTermsReturn, error)

CreateProductAttributeTerms is to create a new term

func DeleteProductAttributeTerms

func DeleteProductAttributeTerms(attributeId, termId int, force bool, r Request) (ProductAttributeTermsReturn, error)

DeleteProductAttributeTerms is to delete a term

func ProductAttributeTerms

func ProductAttributeTerms(attributeId int, r Request) ([]ProductAttributeTermsReturn, error)

ProductAttributeTerms is to get all terms

func UpdateProductAttributeTerms

func UpdateProductAttributeTerms(attributeId, termId int, body ProductAttributeTermBody, r Request) (ProductAttributeTermsReturn, error)

UpdateProductAttributeTerms is to update a term

type ProductAttributesBody

type ProductAttributesBody struct {
	Name        string `json:"name,omitempty"`
	Slug        string `json:"slug,omitempty"`
	Type        string `json:"type,omitempty"`
	OrderBy     string `json:"order_by,omitempty"`
	HasArchives bool   `json:"has_archives,omitempty"`
}

ProductAttributesBody is to structure the data

type ProductAttributesReturn

type ProductAttributesReturn struct {
	Id          int    `json:"id"`
	Name        string `json:"name"`
	Slug        string `json:"slug"`
	Type        string `json:"type"`
	OrderBy     string `json:"order_by"`
	HasArchives bool   `json:"has_archives"`
	Links       struct {
		Self []struct {
			Href string `json:"href"`
		} `json:"self"`
		Collection []struct {
			Href string `json:"href"`
		} `json:"collection"`
	} `json:"_links"`
}

ProductAttributesReturn is to decode the data

func CreateProductAttributes

func CreateProductAttributes(body ProductAttributesBody, r Request) (ProductAttributesReturn, error)

CreateProductAttributes is to create a new attribute

func DeleteProductAttributes

func DeleteProductAttributes(id int, r Request) (ProductAttributesReturn, error)

DeleteProductAttributes is to delete a product attribute

func ProductAttributes

func ProductAttributes(r Request) ([]ProductAttributesReturn, error)

ProductAttributes is to get a list of all product attributes

func UpdateProductAttributes

func UpdateProductAttributes(id int, body ProductAttributesBody, r Request) (ProductAttributesReturn, error)

UpdateProductAttributes is to update a attribute

type ProductCategoriesReturn

type ProductCategoriesReturn struct {
	Id          int         `json:"id"`
	Name        string      `json:"name"`
	Slug        string      `json:"slug"`
	Parent      int         `json:"parent"`
	Description string      `json:"description"`
	Display     string      `json:"display"`
	Image       interface{} `json:"image"`
	MenuOrder   int         `json:"menu_order"`
	Count       int         `json:"count"`
	Links       struct {
		Self []struct {
			Href string `json:"href"`
		} `json:"self"`
		Collection []struct {
			Href string `json:"href"`
		} `json:"collection"`
	} `json:"_links"`
}

ProductCategoriesReturn is to decode the json data

func AddProductCategory

func AddProductCategory(body ProductCategory, r Request) (ProductCategoriesReturn, error)

AddProductCategory is to create a new category

func DeleteProductCategory

func DeleteProductCategory(id int, force bool, r Request) (ProductCategoriesReturn, error)

DeleteProductCategory is to delete a product category

func ProductCategories

func ProductCategories(r Request) ([]ProductCategoriesReturn, error)

ProductCategories is to get a list of all product categories

func UpdateProductCategory

func UpdateProductCategory(id int, body ProductCategory, r Request) (ProductCategoriesReturn, error)

UpdateProductCategory is to update an existing category

type ProductCategory

type ProductCategory struct {
	Name        string               `json:"name,omitempty"`
	Parent      int                  `json:"parent,omitempty"`
	Description string               `json:"description,omitempty"`
	Display     string               `json:"display,omitempty"`
	MenuOrder   int                  `json:"menu_order,omitempty"`
	Image       ProductCategoryImage `json:"image,omitempty"`
}

ProductCategory is to structure the category data

type ProductCategoryImage

type ProductCategoryImage struct {
	Src string `json:"src,omitempty"`
}

type ProductTagsBody

type ProductTagsBody struct {
	Name        string `json:"name"`
	Slug        string `json:"slug,omitempty"`
	Description string `json:"description,omitempty"`
}

ProductTagsBody is to structure the body data

type ProductTagsReturn

type ProductTagsReturn struct {
	Id          int    `json:"id"`
	Name        string `json:"name"`
	Slug        string `json:"slug"`
	Description string `json:"description"`
	Count       int    `json:"count"`
	Links       struct {
		Self []struct {
			Href string `json:"href"`
		} `json:"self"`
		Collection []struct {
			Href string `json:"href"`
		} `json:"collection"`
	} `json:"_links"`
}

ProductTagsReturn is to decode the json data

func CreateProductTag

func CreateProductTag(body ProductTagsBody, r Request) (ProductTagsReturn, error)

CreateProductTag is to create a new product tag

func DeleteProductTag

func DeleteProductTag(id int, force bool, r Request) (ProductTagsReturn, error)

DeleteProductTag is to delete an existing product tag

func ProductTag

func ProductTag(id int, r Request) (ProductTagsReturn, error)

ProductTag is get a product tag

func ProductTags

func ProductTags(r Request) ([]ProductTagsReturn, error)

ProductTags is get a list of all product tags

func UpdateProductTag

func UpdateProductTag(id int, body ProductTagsBody, r Request) (ProductTagsReturn, error)

UpdateProductTag is to update an existing product tag

type ProductVariationsBody

type ProductVariationsBody struct {
	Description       string                            `json:"description,omitempty"`
	Permalink         string                            `json:"permalink,omitempty"`
	Sku               string                            `json:"sku,omitempty"`
	Price             string                            `json:"price,omitempty"`
	RegularPrice      string                            `json:"regular_price,omitempty"`
	SalePrice         string                            `json:"sale_price,omitempty"`
	DateOnSaleFrom    interface{}                       `json:"date_on_sale_from,omitempty"`
	DateOnSaleFromGmt interface{}                       `json:"date_on_sale_from_gmt,omitempty"`
	DateOnSaleTo      interface{}                       `json:"date_on_sale_to,omitempty"`
	DateOnSaleToGmt   interface{}                       `json:"date_on_sale_to_gmt,omitempty"`
	OnSale            bool                              `json:"on_sale,omitempty"`
	Status            string                            `json:"status,omitempty"`
	Purchasable       bool                              `json:"purchasable,omitempty"`
	Virtual           bool                              `json:"virtual,omitempty"`
	Downloadable      bool                              `json:"downloadable,omitempty"`
	Downloads         []interface{}                     `json:"downloads,omitempty"`
	DownloadLimit     int                               `json:"download_limit,omitempty"`
	DownloadExpiry    int                               `json:"download_expiry,omitempty"`
	TaxStatus         string                            `json:"tax_status,omitempty"`
	TaxClass          string                            `json:"tax_class,omitempty"`
	ManageStock       bool                              `json:"manage_stock,omitempty"`
	StockQuantity     interface{}                       `json:"stock_quantity,omitempty"`
	StockStatus       string                            `json:"stock_status,omitempty"`
	Backorders        string                            `json:"backorders,omitempty"`
	BackordersAllowed bool                              `json:"backorders_allowed,omitempty"`
	Backordered       bool                              `json:"backordered,omitempty"`
	Weight            string                            `json:"weight,omitempty"`
	Dimensions        ProductVariationsBodyDimensions   `json:"dimensions,omitempty"`
	ShippingClass     string                            `json:"shipping_class,omitempty"`
	ShippingClassId   int                               `json:"shipping_class_id,omitempty"`
	Image             ProductVariationsBodyImages       `json:"image,omitempty"`
	Attributes        []ProductVariationsBodyAttributes `json:"attributes,omitempty"`
	MenuOrder         int                               `json:"menu_order,omitempty"`
	MetaData          []interface{}                     `json:"meta_data,omitempty"`
}

ProductVariationsBody are to structure the data

type ProductVariationsBodyAttributes

type ProductVariationsBodyAttributes struct {
	Name   string `json:"name,omitempty"`
	Option string `json:"option,omitempty"`
}

type ProductVariationsBodyDimensions

type ProductVariationsBodyDimensions struct {
	Length string `json:"length,omitempty"`
	Width  string `json:"width,omitempty"`
	Height string `json:"height,omitempty"`
}

type ProductVariationsBodyImages

type ProductVariationsBodyImages struct {
	Src  string `json:"src,omitempty"`
	Name string `json:"name,omitempty"`
	Alt  string `json:"alt,omitempty"`
}

type ProductVariationsReturn

type ProductVariationsReturn struct {
	Id                int           `json:"id"`
	DateCreated       string        `json:"date_created"`
	DateCreatedGmt    string        `json:"date_created_gmt"`
	DateModified      string        `json:"date_modified"`
	DateModifiedGmt   string        `json:"date_modified_gmt"`
	Description       string        `json:"description"`
	Permalink         string        `json:"permalink"`
	Sku               string        `json:"sku"`
	Price             string        `json:"price"`
	RegularPrice      string        `json:"regular_price"`
	SalePrice         string        `json:"sale_price"`
	DateOnSaleFrom    interface{}   `json:"date_on_sale_from"`
	DateOnSaleFromGmt interface{}   `json:"date_on_sale_from_gmt"`
	DateOnSaleTo      interface{}   `json:"date_on_sale_to"`
	DateOnSaleToGmt   interface{}   `json:"date_on_sale_to_gmt"`
	OnSale            bool          `json:"on_sale"`
	Status            string        `json:"status"`
	Purchasable       bool          `json:"purchasable"`
	Virtual           bool          `json:"virtual"`
	Downloadable      bool          `json:"downloadable"`
	Downloads         []interface{} `json:"downloads"`
	DownloadLimit     int           `json:"download_limit"`
	DownloadExpiry    int           `json:"download_expiry"`
	TaxStatus         string        `json:"tax_status"`
	TaxClass          string        `json:"tax_class"`
	ManageStock       bool          `json:"manage_stock"`
	StockQuantity     int           `json:"stock_quantity"`
	StockStatus       string        `json:"stock_status"`
	Backorders        string        `json:"backorders"`
	BackordersAllowed bool          `json:"backorders_allowed"`
	Backordered       bool          `json:"backordered"`
	LowStockAmount    interface{}   `json:"low_stock_amount"`
	Weight            string        `json:"weight"`
	Dimensions        struct {
		Length string `json:"length"`
		Width  string `json:"width"`
		Height string `json:"height"`
	} `json:"dimensions"`
	ShippingClass   string `json:"shipping_class"`
	ShippingClassId int    `json:"shipping_class_id"`
	Image           struct {
		Id              int    `json:"id"`
		DateCreated     string `json:"date_created"`
		DateCreatedGmt  string `json:"date_created_gmt"`
		DateModified    string `json:"date_modified"`
		DateModifiedGmt string `json:"date_modified_gmt"`
		Src             string `json:"src"`
		Name            string `json:"name"`
		Alt             string `json:"alt"`
	} `json:"image"`
	Attributes []struct {
		Id     int    `json:"id"`
		Name   string `json:"name"`
		Option string `json:"option"`
	} `json:"attributes"`
	MenuOrder int           `json:"menu_order"`
	MetaData  []interface{} `json:"meta_data"`
	Links     struct {
		Self []struct {
			Href string `json:"href"`
		} `json:"self"`
		Collection []struct {
			Href string `json:"href"`
		} `json:"collection"`
		Up []struct {
			Href string `json:"href"`
		} `json:"up"`
	} `json:"_links"`
	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
	Data    struct {
		Status int `json:"status"`
		Params struct {
			StockStatus string `json:"stock_status"`
		} `json:"params"`
		Details struct {
			StockStatus struct {
				Code    string      `json:"code"`
				Message string      `json:"message"`
				Data    interface{} `json:"data"`
			} `json:"stock_status"`
		} `json:"details"`
	} `json:"data,omitempty"`
}

ProductVariationsReturn is to decode the json data

func CreateProductVariations

func CreateProductVariations(productId int, body ProductVariationsBody, r Request) (ProductVariationsReturn, error)

CreateProductVariations is to create a new variant to a product

func DeleteProductVariations

func DeleteProductVariations(productId, variantId int, r Request) (ProductVariationsReturn, error)

DeleteProductVariations is to remove a variant from a product

func ProductVariations

func ProductVariations(productId, page int, r Request) ([]ProductVariationsReturn, error)

ProductVariations is to get a list of all product variations

func UpdateProductVariations

func UpdateProductVariations(productId, variantId int, body ProductVariationsBody, r Request) (ProductVariationsReturn, error)

UpdateProductVariations is to create a new variant to a product

type ProductsBody

type ProductsBody struct {
	Name              string                   `json:"name"`
	Slug              string                   `json:"slug"`
	Type              string                   `json:"type"`
	Status            string                   `json:"status"`
	Featured          bool                     `json:"featured"`
	CatalogVisibility string                   `json:"catalog_visibility"`
	Description       string                   `json:"description"`
	ShortDescription  string                   `json:"short_description"`
	Sku               string                   `json:"sku"`
	Price             string                   `json:"price"`
	RegularPrice      string                   `json:"regular_price"`
	SalePrice         string                   `json:"sale_price"`
	DateOnSaleFrom    interface{}              `json:"date_on_sale_from"`
	DateOnSaleFromGmt interface{}              `json:"date_on_sale_from_gmt"`
	DateOnSaleTo      interface{}              `json:"date_on_sale_to"`
	DateOnSaleToGmt   interface{}              `json:"date_on_sale_to_gmt"`
	OnSale            bool                     `json:"on_sale"`
	Purchasable       bool                     `json:"purchasable"`
	TotalSales        int                      `json:"total_sales"`
	Virtual           bool                     `json:"virtual"`
	Downloadable      bool                     `json:"downloadable"`
	Downloads         []interface{}            `json:"downloads"`
	DownloadLimit     int                      `json:"download_limit"`
	DownloadExpiry    int                      `json:"download_expiry"`
	ExternalUrl       string                   `json:"external_url"`
	ButtonText        string                   `json:"button_text"`
	TaxStatus         string                   `json:"tax_status"`
	TaxClass          string                   `json:"tax_class"`
	ManageStock       bool                     `json:"manage_stock"`
	StockQuantity     interface{}              `json:"stock_quantity"`
	Backorders        string                   `json:"backorders"`
	BackordersAllowed bool                     `json:"backorders_allowed"`
	Backordered       bool                     `json:"backordered"`
	LowStockAmount    interface{}              `json:"low_stock_amount"`
	SoldIndividually  bool                     `json:"sold_individually"`
	Weight            string                   `json:"weight"`
	Dimensions        ProductsBodyDimensions   `json:"dimensions,omitempty"`
	ShippingRequired  bool                     `json:"shipping_required"`
	ShippingTaxable   bool                     `json:"shipping_taxable"`
	ShippingClass     string                   `json:"shipping_class"`
	ShippingClassId   int                      `json:"shipping_class_id"`
	ReviewsAllowed    bool                     `json:"reviews_allowed"`
	AverageRating     string                   `json:"average_rating"`
	RatingCount       int                      `json:"rating_count"`
	UpsellIds         []interface{}            `json:"upsell_ids"`
	CrossSellIds      []interface{}            `json:"cross_sell_ids"`
	ParentId          int                      `json:"parent_id"`
	PurchaseNote      string                   `json:"purchase_note"`
	Categories        []ProductsBodyCategories `json:"categories,omitempty"`
	Tags              []ProductsBodyTags       `json:"tags,omitempty"`
	Images            []ProductsBodyImages     `json:"images,omitempty"`
	Attributes        []ProductsBodyAttributes `json:"attributes,omitempty"`
	DefaultAttributes []interface{}            `json:"default_attributes"`
	Variations        []interface{}            `json:"variations"`
	GroupedProducts   []interface{}            `json:"grouped_products"`
	MenuOrder         int                      `json:"menu_order"`
	RelatedIds        []interface{}            `json:"related_ids"`
	MetaData          []interface{}            `json:"meta_data"`
	StockStatus       string                   `json:"stock_status"`
}

ProductsBody is to structure the request data

type ProductsBodyAttributes

type ProductsBodyAttributes struct {
	Name      string   `json:"name"`
	Position  int      `json:"position"`
	Visible   bool     `json:"visible"`
	Variation bool     `json:"variation"`
	Options   []string `json:"options"`
}

type ProductsBodyCategories

type ProductsBodyCategories struct {
	Id   int    `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
	Slug string `json:"slug,omitempty"`
}

type ProductsBodyDimensions

type ProductsBodyDimensions struct {
	Length string `json:"length,omitempty"`
	Width  string `json:"width,omitempty"`
	Height string `json:"height,omitempty"`
}

type ProductsBodyImages

type ProductsBodyImages struct {
	Src  string `json:"src,omitempty"`
	Name string `json:"name,omitempty"`
	Alt  string `json:"alt,omitempty"`
}

type ProductsBodyTags

type ProductsBodyTags struct {
	Id   int    `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
	Slug string `json:"slug,omitempty"`
}

type ProductsReturn

type ProductsReturn struct {
	Id                int           `json:"id"`
	Name              string        `json:"name"`
	Slug              string        `json:"slug"`
	Permalink         string        `json:"permalink"`
	DateCreated       string        `json:"date_created"`
	DateCreatedGmt    string        `json:"date_created_gmt"`
	DateModified      string        `json:"date_modified"`
	DateModifiedGmt   string        `json:"date_modified_gmt"`
	Type              string        `json:"type"`
	Status            string        `json:"status"`
	Featured          bool          `json:"featured"`
	CatalogVisibility string        `json:"catalog_visibility"`
	Description       string        `json:"description"`
	ShortDescription  string        `json:"short_description"`
	Sku               string        `json:"sku"`
	Price             string        `json:"price"`
	RegularPrice      string        `json:"regular_price"`
	SalePrice         string        `json:"sale_price"`
	DateOnSaleFrom    interface{}   `json:"date_on_sale_from"`
	DateOnSaleFromGmt interface{}   `json:"date_on_sale_from_gmt"`
	DateOnSaleTo      interface{}   `json:"date_on_sale_to"`
	DateOnSaleToGmt   interface{}   `json:"date_on_sale_to_gmt"`
	OnSale            bool          `json:"on_sale"`
	Purchasable       bool          `json:"purchasable"`
	TotalSales        int           `json:"total_sales"`
	Virtual           bool          `json:"virtual"`
	Downloadable      bool          `json:"downloadable"`
	Downloads         []interface{} `json:"downloads"`
	DownloadLimit     int           `json:"download_limit"`
	DownloadExpiry    int           `json:"download_expiry"`
	ExternalUrl       string        `json:"external_url"`
	ButtonText        string        `json:"button_text"`
	TaxStatus         string        `json:"tax_status"`
	TaxClass          string        `json:"tax_class"`
	ManageStock       bool          `json:"manage_stock"`
	StockQuantity     interface{}   `json:"stock_quantity"`
	Backorders        string        `json:"backorders"`
	BackordersAllowed bool          `json:"backorders_allowed"`
	Backordered       bool          `json:"backordered"`
	LowStockAmount    interface{}   `json:"low_stock_amount"`
	SoldIndividually  bool          `json:"sold_individually"`
	Weight            string        `json:"weight"`
	Dimensions        struct {
		Length string `json:"length"`
		Width  string `json:"width"`
		Height string `json:"height"`
	} `json:"dimensions"`
	ShippingRequired bool          `json:"shipping_required"`
	ShippingTaxable  bool          `json:"shipping_taxable"`
	ShippingClass    string        `json:"shipping_class"`
	ShippingClassId  int           `json:"shipping_class_id"`
	ReviewsAllowed   bool          `json:"reviews_allowed"`
	AverageRating    string        `json:"average_rating"`
	RatingCount      int           `json:"rating_count"`
	UpsellIds        []interface{} `json:"upsell_ids"`
	CrossSellIds     []interface{} `json:"cross_sell_ids"`
	ParentId         int           `json:"parent_id"`
	PurchaseNote     string        `json:"purchase_note"`
	Categories       []struct {
		Id   int    `json:"id"`
		Name string `json:"name"`
		Slug string `json:"slug"`
	} `json:"categories"`
	Tags              []interface{} `json:"tags"`
	Images            []interface{} `json:"images"`
	Attributes        []interface{} `json:"attributes"`
	DefaultAttributes []interface{} `json:"default_attributes"`
	Variations        []interface{} `json:"variations"`
	GroupedProducts   []interface{} `json:"grouped_products"`
	MenuOrder         int           `json:"menu_order"`
	PriceHtml         string        `json:"price_html"`
	RelatedIds        []interface{} `json:"related_ids"`
	MetaData          []interface{} `json:"meta_data"`
	StockStatus       string        `json:"stock_status"`
	Links             struct {
		Self []struct {
			Href string `json:"href"`
		} `json:"self"`
		Collection []struct {
			Href string `json:"href"`
		} `json:"collection"`
	} `json:"_links"`
	Code    string `json:"code"`
	Message string `json:"message"`
	Data    struct {
		Status int `json:"status"`
		Params struct {
			Backorders string `json:"backorders"`
		} `json:"params"`
		Details struct {
			Backorders struct {
				Code    string      `json:"code"`
				Message string      `json:"message"`
				Data    interface{} `json:"data"`
			} `json:"backorders"`
		} `json:"details"`
	} `json:"data"`
}

ProductsReturn is to decode the product return

func CreateProduct

func CreateProduct(body ProductsBody, r Request) (ProductsReturn, error)

CreateProduct is to create a new product

func DeleteProduct

func DeleteProduct(id int, force bool, r Request) (ProductsReturn, error)

DeleteProduct is to remove a product from woocommerce

func Products

func Products(page int, r Request) ([]ProductsReturn, error)

Products are to get a list of all products per page

func UpdateProduct

func UpdateProduct(id int, body ProductsBody, r Request) (ProductsReturn, error)

UpdateProduct is to update a product

type Request

type Request struct {
	BaseUrl, ConsumerKey, ConsumerSecret string
}

Request is to define the request data

type UpdateOrderBody added in v1.2.8

type UpdateOrderBody struct {
	Id     int    `json:"id"`
	Status string `json:"status"`
}

UpdateOrderBody is to structure the data

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL