woocommerce

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: BSD-3-Clause Imports: 29 Imported by: 0

README

WooCommerce SDK for golang

Docs

Rest API Docs

https://woocommerce.github.io/woocommerce-rest-api-docs/#introduction

Requirements

To use the latest version of the REST API you must be using:

  • WooCommerce 3.5+.
  • WordPress 4.4+.

Pretty permalinks in Settings > Permalinks so that the custom endpoints are supported. Default permalinks will not work. You may access the API over either HTTP or HTTPS, but HTTPS is recommended where possible. If you use ModSecurity and see 501 Method Not Implemented errors, see this issue for details.

Notices

Only tested in API v3, if you are use v1 or v2, please Report an issue.

Install

go get github.com/hiscaler/woocommerce-go

Config

{
  "debug": true,
  "url": "http://127.0.0.1/",
  "version": "v3",
  "consumer_key": "",
  "consumer_secret": "",
  "add_authentication_to_url": false,
  "timeout": 10,
  "verify_ssl": true
}

Usage

Step 1. Create a new client
// Read you config
b, err := os.ReadFile("./config/config_test.json")
if err != nil {
    panic(fmt.Sprintf("Read config error: %s", err.Error()))
}
var c config.Config
err = jsoniter.Unmarshal(b, &c)
if err != nil {
    panic(fmt.Sprintf("Parse config file error: %s", err.Error()))
}

wooClient := NewClient(c)

Now you get a wooCommerce client object, If you want operate data, please refer second step.

Step 2. Call special service method
// Product Query
params := ProductsQueryParams{}
wooClient.Services.Product.All(params)

10 records are returned by default.

In most cases, you can filter by condition, example:

params.SKU = "NO123"
wooClient.Services.Product.All(params)

The first ten eligible records are returned in this case

And you can retrieve one data use One() method.

product, err := wooClient.Services.Product.One(1)

Note: If the error type is ErrNotFound, it indicates that the corresponding data is not found. If the error type is other error, an error may occur in the call. So you should judge the results to further process your business logic.

Services

Coupons

Service Name: wooClient.Service.Coupon

Methods:

  • All
  • Batch
  • Create
  • Delete
  • One
  • Update
Customers

Service Name: wooClient.Service.Customer

Methods:

  • All
  • Batch
  • Create
  • Delete
  • Downloads
  • One
  • Update
Order

Service Name: wooClient.Service.Order

Methods:

  • All
  • Create
  • Delete
  • One
  • Update
Order Notes

Service Name: wooClient.Service.OrderNote

Methods:

  • All
  • Create
  • Delete
  • One
Refunds

Service Name: wooClient.Service.OrderRefund

Methods:

  • All
  • Create
  • Delete
  • One
Products

Service Name: wooClient.Service.Product

Methods:

  • All
  • Create
  • Delete
  • One
  • Update
Product Variations

Service Name: wooClient.Service.ProductVariation

Methods:

  • All
  • Batch
  • Create
  • Delete
  • One
  • Update
Product Attributes

Service Name: wooClient.Service.ProductAttribute

Methods:

  • All
  • Batch
  • Create
  • Delete
  • One
  • Update
Product Attribute Terms

Service Name: wooClient.Service.ProductAttributeTerm

Methods:

  • All
  • Batch
  • Create
  • Delete
  • One
  • Update
Product Categories

Service Name: wooClient.Service.ProductCategory

Methods:

  • All
  • Batch
  • Create
  • Delete
  • One
  • Update
Product Shipping Classes

Service Name: wooClient.Service.ProductShippingClass

Methods:

  • All
  • Batch
  • Create
  • Delete
  • One
  • Update
Product Tags

Service Name: wooClient.Service.ProductTag

Methods:

  • All
  • Batch
  • Create
  • Delete
  • One
  • Update
Product Reviews

Service Name: wooClient.Service.ProductReview

Methods:

  • All
  • Batch
  • Create
  • Delete
  • One
  • Update
Report

Service Name: wooClient.Service.Report

Methods:

  • All
  • CouponTotals
  • CustomerTotals
  • OrderTotals
  • ProductTotals
  • ReviewTotals
  • SalesReports
  • TopSellerReports
Tax Rates

Service Name: wooClient.Service.TaxRate

Methods:

  • All
  • Batch
  • Create
  • Delete
  • One
  • Update
Tax Classes

Service Name: wooClient.Service.TaxClass

Methods:

  • All
  • Create
  • Delete
Webhooks

Service Name: wooClient.Service.Webhook

Methods:

  • All
  • Batch
  • Create
  • Delete
  • One
  • Update
Settings
  • Groups

Service Name: wooClient.Service.Group

Methods:

Setting Options
  • All
  • One
  • Update
Payment Gateways

Service Name: wooClient.Service.PaymentGateway

Methods:

  • All
  • One
  • Update
Shipping Zones

Service Name: wooClient.Service.ShippingZone

Methods:

  • All
  • Create
  • Delete
  • One
  • Update
Shipping Zone Locations

Service Name: wooClient.Service.ShippingZoneLocation

Methods:

  • All
  • Update
Shipping Zone Methods

Service Name: wooClient.Service.ShippingZoneMethod

Methods:

  • All
  • Delete
  • Include
  • One
  • Update
Shipping Methods

Service Name: wooClient.Service.ShippingMethod

Methods:

  • All
  • One
System Status

Service Name: wooClient.Service.SystemStatus

Methods:

  • All
System Status Tools

Service Name: wooClient.Service.SystemStatusTool

Methods:

  • All
  • One
  • Run
Data

Service Name: wooClient.Service.Data

Methods:

  • All
  • Continent
  • Continents
  • Countries
  • Country
  • Currencies
  • Currency
  • CurrentCurrency

Contributing

If you have any questions or suggestions, you can:

  1. Report an issue
  2. Fork it and pull a request

Thanks.

Documentation

Index

Constants

View Source
const (
	SortAsc  = "asc"
	SortDesc = "desc"
)
View Source
const (
	ViewContext = "view"
	EditContext = "edit"
)
View Source
const (
	Version       = "1.0.0"
	UserAgent     = "WooCommerce API Client-Golang/" + Version
	HashAlgorithm = "HMAC-SHA256"
)
View Source
const (
	BadRequestError         = 400 // 错误的请求
	UnauthorizedError       = 401 // 身份验证或权限错误
	NotFoundError           = 404 // 访问资源不存在
	InternalServerError     = 500 // 服务器内部错误
	MethodNotImplementedErr = 501 // 方法未实现
)

https://woocommerce.github.io/woocommerce-rest-api-docs/?php#request-response-format

Variables

View Source
var ErrNotFound = errors.New("WooCommerce: not found")

Functions

func ErrorWrap

func ErrorWrap(code int, message string) error

ErrorWrap 错误包装

func IsValidateTime added in v1.0.3

func IsValidateTime(dateStr string) error

IsValidateTime Is validate time

func ToISOTimeString added in v1.0.3

func ToISOTimeString(dateStr string, addMinTimeString, addMaxTimeString bool) (s string)

ToISOTimeString Convert to iso time string If date format is invalid, then return original value If dateStr include time part, and you set addMinTimeString/addMaxTimeString to true, but still return original dateStr value.

Types

type BatchCouponsCreateItem

type BatchCouponsCreateItem = CreateCouponRequest

type BatchCouponsRequest

type BatchCouponsRequest struct {
	Create []BatchCouponsCreateItem `json:"create,omitempty"`
	Update []BatchCouponsUpdateItem `json:"update,omitempty"`
	Delete []int                    `json:"delete,omitempty"`
}

func (BatchCouponsRequest) Validate

func (m BatchCouponsRequest) Validate() error

type BatchCouponsResult

type BatchCouponsResult struct {
	Create []entity.Coupon `json:"create"`
	Update []entity.Coupon `json:"update"`
	Delete []entity.Coupon `json:"delete"`
}

type BatchCouponsUpdateItem

type BatchCouponsUpdateItem struct {
	ID string `json:"id"`
	BatchCouponsCreateItem
}

type BatchCreateCustomerRequest

type BatchCreateCustomerRequest = CreateCustomerRequest

type BatchCustomerRequest

type BatchCustomerRequest struct {
	Create []BatchCreateCustomerRequest `json:"create,omitempty"`
	Update []BatchUpdateCustomerRequest `json:"update,omitempty"`
	Delete []int                        `json:"delete,omitempty"`
}

func (BatchCustomerRequest) Validate

func (m BatchCustomerRequest) Validate() error

type BatchCustomerResult

type BatchCustomerResult struct {
	Create []entity.Customer `json:"create"`
	Update []entity.Customer `json:"update"`
	Delete []entity.Customer `json:"delete"`
}

type BatchProductAttributeTermsCreateItem

type BatchProductAttributeTermsCreateItem = CreateProductAttributeTermRequest

type BatchProductAttributeTermsRequest

type BatchProductAttributeTermsRequest struct {
	Create []BatchProductAttributeTermsCreateItem `json:"create,omitempty"`
	Update []BatchProductAttributeTermsUpdateItem `json:"update,omitempty"`
	Delete []int                                  `json:"delete,omitempty"`
}

func (BatchProductAttributeTermsRequest) Validate

type BatchProductAttributeTermsResult

type BatchProductAttributeTermsResult struct {
	Create []entity.ProductAttributeTerm `json:"create"`
	Update []entity.ProductAttributeTerm `json:"update"`
	Delete []entity.ProductAttributeTerm `json:"delete"`
}

type BatchProductAttributeTermsUpdateItem

type BatchProductAttributeTermsUpdateItem struct {
	ID string `json:"id"`
	BatchProductAttributeTermsCreateItem
}

type BatchProductAttributesCreateItem

type BatchProductAttributesCreateItem = CreateProductAttributeRequest

type BatchProductAttributesRequest

type BatchProductAttributesRequest struct {
	Create []BatchProductAttributesCreateItem `json:"create,omitempty"`
	Update []BatchProductAttributesUpdateItem `json:"update,omitempty"`
	Delete []int                              `json:"delete,omitempty"`
}

func (BatchProductAttributesRequest) Validate

func (m BatchProductAttributesRequest) Validate() error

type BatchProductAttributesResult

type BatchProductAttributesResult struct {
	Create []entity.ProductAttribute `json:"create"`
	Update []entity.ProductAttribute `json:"update"`
	Delete []entity.ProductAttribute `json:"delete"`
}

type BatchProductAttributesUpdateItem

type BatchProductAttributesUpdateItem struct {
	ID string `json:"id"`
	BatchProductAttributesCreateItem
}

type BatchProductCategoriesCreateItem

type BatchProductCategoriesCreateItem = UpsertProductCategoryRequest

type BatchProductCategoriesRequest

type BatchProductCategoriesRequest struct {
	Create []BatchProductCategoriesCreateItem `json:"create,omitempty"`
	Update []BatchProductCategoriesUpdateItem `json:"update,omitempty"`
	Delete []int                              `json:"delete,omitempty"`
}

func (BatchProductCategoriesRequest) Validate

func (m BatchProductCategoriesRequest) Validate() error

type BatchProductCategoriesResult

type BatchProductCategoriesResult struct {
	Create []entity.ProductTag `json:"create"`
	Update []entity.ProductTag `json:"update"`
	Delete []entity.ProductTag `json:"delete"`
}

type BatchProductCategoriesUpdateItem

type BatchProductCategoriesUpdateItem struct {
	ID int `json:"id"`
	UpsertProductTagRequest
}

type BatchProductReviewsCreateItem

type BatchProductReviewsCreateItem = CreateProductReviewRequest

type BatchProductReviewsRequest

type BatchProductReviewsRequest struct {
	Create []BatchProductReviewsCreateItem `json:"create,omitempty"`
	Update []BatchProductReviewsUpdateItem `json:"update,omitempty"`
	Delete []int                           `json:"delete,omitempty"`
}

func (BatchProductReviewsRequest) Validate

func (m BatchProductReviewsRequest) Validate() error

type BatchProductReviewsResult

type BatchProductReviewsResult struct {
	Create []entity.ProductReview `json:"create"`
	Update []entity.ProductReview `json:"update"`
	Delete []entity.ProductReview `json:"delete"`
}

type BatchProductReviewsUpdateItem

type BatchProductReviewsUpdateItem struct {
	ID string `json:"id"`
	BatchProductReviewsCreateItem
}

type BatchProductShippingClassesCreateItem

type BatchProductShippingClassesCreateItem = CreateProductShippingClassRequest

type BatchProductShippingClassesRequest

type BatchProductShippingClassesRequest struct {
	Create []BatchProductShippingClassesCreateItem `json:"create,omitempty"`
	Update []BatchProductShippingClassesUpdateItem `json:"update,omitempty"`
	Delete []int                                   `json:"delete,omitempty"`
}

func (BatchProductShippingClassesRequest) Validate

type BatchProductShippingClassesResult

type BatchProductShippingClassesResult struct {
	Create []entity.ProductShippingClass `json:"create"`
	Update []entity.ProductShippingClass `json:"update"`
	Delete []entity.ProductShippingClass `json:"delete"`
}

type BatchProductShippingClassesUpdateItem

type BatchProductShippingClassesUpdateItem struct {
	ID string `json:"id"`
	BatchProductShippingClassesCreateItem
}

type BatchProductTagsCreateItem

type BatchProductTagsCreateItem = UpsertProductTagRequest

type BatchProductTagsRequest

type BatchProductTagsRequest struct {
	Create []BatchProductTagsCreateItem `json:"create,omitempty"`
	Update []BatchProductTagsUpdateItem `json:"update,omitempty"`
	Delete []int                        `json:"delete,omitempty"`
}

func (BatchProductTagsRequest) Validate

func (m BatchProductTagsRequest) Validate() error

type BatchProductTagsResult

type BatchProductTagsResult struct {
	Create []entity.ProductTag `json:"create"`
	Update []entity.ProductTag `json:"update"`
	Delete []entity.ProductTag `json:"delete"`
}

type BatchProductTagsUpdateItem

type BatchProductTagsUpdateItem struct {
	ID int `json:"id"`
	UpsertProductTagRequest
}

type BatchProductVariationsCreateItem

type BatchProductVariationsCreateItem = CreateProductVariationRequest

type BatchProductVariationsRequest

type BatchProductVariationsRequest struct {
	Create []BatchProductVariationsCreateItem `json:"create,omitempty"`
	Update []BatchProductVariationsUpdateItem `json:"update,omitempty"`
	Delete []int                              `json:"delete,omitempty"`
}

func (BatchProductVariationsRequest) Validate

func (m BatchProductVariationsRequest) Validate() error

type BatchProductVariationsResult

type BatchProductVariationsResult struct {
	Create []entity.ProductVariation `json:"create"`
	Update []entity.ProductVariation `json:"update"`
	Delete []entity.ProductVariation `json:"delete"`
}

type BatchProductVariationsUpdateItem

type BatchProductVariationsUpdateItem struct {
	ID int `json:"id"`
	CreateProductVariationRequest
}

type BatchTaxRatesCreateItem

type BatchTaxRatesCreateItem = CreateTaxRateRequest

type BatchTaxRatesRequest

type BatchTaxRatesRequest struct {
	Create []BatchTaxRatesCreateItem `json:"create,omitempty"`
	Update []BatchTaxRatesUpdateItem `json:"update,omitempty"`
	Delete []int                     `json:"delete,omitempty"`
}

func (BatchTaxRatesRequest) Validate

func (m BatchTaxRatesRequest) Validate() error

type BatchTaxRatesResult

type BatchTaxRatesResult struct {
	Create []entity.TaxRate `json:"create"`
	Update []entity.TaxRate `json:"update"`
	Delete []entity.TaxRate `json:"delete"`
}

type BatchTaxRatesUpdateItem

type BatchTaxRatesUpdateItem struct {
	ID string `json:"id"`
	BatchTaxRatesCreateItem
}

type BatchUpdateCustomerRequest

type BatchUpdateCustomerRequest struct {
	ID string `json:"id"`
	BatchCreateCustomerRequest
}

type BatchWebhooksCreateItem

type BatchWebhooksCreateItem = CreateWebhookRequest

type BatchWebhooksRequest

type BatchWebhooksRequest struct {
	Create []BatchWebhooksCreateItem `json:"create,omitempty"`
	Update []BatchWebhooksUpdateItem `json:"update,omitempty"`
	Delete []int                     `json:"delete,omitempty"`
}

func (BatchWebhooksRequest) Validate

func (m BatchWebhooksRequest) Validate() error

type BatchWebhooksResult

type BatchWebhooksResult struct {
	Create []entity.Webhook `json:"create"`
	Update []entity.Webhook `json:"update"`
	Delete []entity.Webhook `json:"delete"`
}

type BatchWebhooksUpdateItem

type BatchWebhooksUpdateItem struct {
	ID string `json:"id"`
	BatchWebhooksCreateItem
}

type CouponsQueryParams

type CouponsQueryParams struct {
	Search  string `url:"search,omitempty"`
	After   string `url:"after,omitempty"`
	Before  string `url:"before,omitempty"`
	Exclude []int  `url:"exclude,omitempty"`
	Include []int  `url:"include,omitempty"`
	Code    string `url:"code,omitempty"`
	// contains filtered or unexported fields
}

func (*CouponsQueryParams) TidyVars

func (q *CouponsQueryParams) TidyVars() *queryParams

func (CouponsQueryParams) Validate

func (m CouponsQueryParams) Validate() error

type CreateCouponRequest

type CreateCouponRequest struct {
	Code             string  `json:"code"`
	DiscountType     string  `json:"discount_type"`
	Amount           float64 `json:"amount,string"`
	IndividualUse    bool    `json:"individual_use"`
	ExcludeSaleItems bool    `json:"exclude_sale_items"`
	MinimumAmount    float64 `json:"minimum_amount,string"`
}

func (CreateCouponRequest) Validate

func (m CreateCouponRequest) Validate() error

type CreateCustomerRequest

type CreateCustomerRequest struct {
	Email     string            `json:"email,omitempty"`
	FirstName string            `json:"first_name,omitempty"`
	LastName  string            `json:"last_name,omitempty"`
	Username  string            `json:"username,omitempty"`
	Password  string            `json:"password,omitempty"`
	Billing   *entity.Billing   `json:"billing,omitempty"`
	Shipping  *entity.Shipping  `json:"shipping,omitempty"`
	MetaData  []entity.MetaData `json:"meta_data,omitempty"`
}

CreateCustomerRequest Create customer request

func (CreateCustomerRequest) Validate

func (m CreateCustomerRequest) Validate() error

type CreateOrderNoteRequest

type CreateOrderNoteRequest struct {
	Note string `json:"note"`
}

func (CreateOrderNoteRequest) Validate

func (m CreateOrderNoteRequest) Validate() error

type CreateOrderRefundRequest

type CreateOrderRefundRequest struct {
	Amount     float64                      `json:"amount,string"`
	Reason     string                       `json:"reason,omitempty"`
	RefundedBy int                          `json:"refunded_by,omitempty"`
	MetaData   []entity.MetaData            `json:"meta_data,omitempty"`
	LineItems  []entity.OrderRefundLineItem `json:"line_items,omitempty"`
}

func (CreateOrderRefundRequest) Validate

func (m CreateOrderRefundRequest) Validate() error

type CreateOrderRequest

type CreateOrderRequest struct {
	Status             string                `json:"status,omitempty"`
	Currency           string                `json:"currency,omitempty"`
	CurrencySymbol     string                `json:"currency_symbol,omitempty"`
	PricesIncludeTax   bool                  `json:"prices_include_tax,omitempty"`
	CustomerId         int                   `json:"customer_id,omitempty"`
	CustomerNote       string                `json:"customer_note,omitempty"`
	Billing            *entity.Billing       `json:"billing,omitempty"`
	Shipping           *entity.Shipping      `json:"shipping,omitempty"`
	PaymentMethod      string                `json:"payment_method,omitempty"`
	PaymentMethodTitle string                `json:"payment_method_title,omitempty"`
	TransactionId      string                `json:"transaction_id,omitempty"`
	MetaData           []entity.MetaData     `json:"meta_data,omitempty"`
	LineItems          []entity.LineItem     `json:"line_items,omitempty"`
	TaxLines           []entity.TaxLine      `json:"tax_lines,omitempty"`
	ShippingLines      []entity.ShippingLine `json:"shipping_lines,omitempty"`
	FeeLines           []entity.FeeLine      `json:"fee_lines,omitempty"`
	CouponLines        []entity.CouponLine   `json:"coupon_lines,omitempty"`
	SetPaid            bool                  `json:"set_paid,omitempty"`
}

func (CreateOrderRequest) Validate

func (m CreateOrderRequest) Validate() error

type CreateProductAttributeRequest

type CreateProductAttributeRequest 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"`
}

func (CreateProductAttributeRequest) Validate

func (m CreateProductAttributeRequest) Validate() error

type CreateProductAttributeTermRequest

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

func (CreateProductAttributeTermRequest) Validate

type CreateProductCategoryRequest

type CreateProductCategoryRequest = UpsertProductCategoryRequest

type CreateProductRequest

type CreateProductRequest struct {
	Name              string                           `json:"name,omitempty"`
	Slug              string                           `json:"slug,omitempty"`
	Type              string                           `json:"type,omitempty"`
	Status            string                           `json:"status,omitempty"`
	Featured          bool                             `json:"featured,omitempty"`
	CatalogVisibility string                           `json:"catalog_visibility,omitempty"`
	Description       string                           `json:"description,omitempty"`
	ShortDescription  string                           `json:"short_description,omitempty"`
	SKU               string                           `json:"sku,omitempty"`
	RegularPrice      float64                          `json:"regular_price,string,omitempty"`
	SalePrice         float64                          `json:"sale_price,string,omitempty"`
	DateOnSaleFrom    string                           `json:"date_on_sale_from,omitempty"`
	DateOnSaleFromGMT string                           `json:"date_on_sale_from_gmt,omitempty"`
	DateOnSaleTo      string                           `json:"date_on_sale_to,omitempty"`
	DateOnSaleToGMT   string                           `json:"date_on_sale_to_gmt,omitempty"`
	Virtual           bool                             `json:"virtual,omitempty"`
	Downloadable      bool                             `json:"downloadable,omitempty"`
	Downloads         []entity.ProductDownload         `json:"downloads,omitempty"`
	DownloadLimit     int                              `json:"download_limit,omitempty"`
	DownloadExpiry    int                              `json:"download_expiry,omitempty"`
	ExternalUrl       string                           `json:"external_url,omitempty"`
	ButtonText        string                           `json:"button_text,omitempty"`
	TaxStatus         string                           `json:"tax_status,omitempty"`
	TaxClass          string                           `json:"tax_class,omitempty"`
	ManageStock       bool                             `json:"manage_stock,omitempty"`
	StockQuantity     int                              `json:"stock_quantity,omitempty"`
	StockStatus       string                           `json:"stock_status,omitempty"`
	Backorders        string                           `json:"backorders,omitempty"`
	SoldIndividually  bool                             `json:"sold_individually,omitempty"`
	Weight            string                           `json:"weight,omitempty"`
	Dimensions        *entity.ProductDimension         `json:"dimensions,omitempty"`
	ShippingClass     string                           `json:"shipping_class,omitempty"`
	ReviewsAllowed    bool                             `json:"reviews_allowed,omitempty"`
	UpsellIds         []int                            `json:"upsell_ids,omitempty"`
	CrossSellIds      []int                            `json:"cross_sell_ids,omitempty"`
	ParentId          int                              `json:"parent_id,omitempty"`
	PurchaseNote      string                           `json:"purchase_note,omitempty"`
	Categories        []entity.ProductCategory         `json:"categories,omitempty"`
	Tags              []entity.ProductTag              `json:"tags,omitempty"`
	Images            []entity.ProductImage            `json:"images,omitempty"`
	Attributes        []entity.ProductAttribute        `json:"attributes,omitempty"`
	DefaultAttributes []entity.ProductDefaultAttribute `json:"default_attributes,omitempty"`
	GroupedProducts   []int                            `json:"grouped_products,omitempty"`
	MenuOrder         int                              `json:"menu_order,omitempty"`
	MetaData          []entity.Meta                    `json:"meta_data,omitempty"`
}

func (CreateProductRequest) Validate

func (m CreateProductRequest) Validate() error

type CreateProductReviewRequest

type CreateProductReviewRequest struct {
	ProductId     int    `json:"product_id,omitempty"`
	Status        string `json:"status,omitempty"`
	Reviewer      string `json:"reviewer,omitempty"`
	ReviewerEmail string `json:"reviewer_email,omitempty"`
	Review        string `json:"review,omitempty"`
	Rating        int    `json:"rating,omitempty"`
	Verified      bool   `json:"verified,omitempty"`
}

func (CreateProductReviewRequest) Validate

func (m CreateProductReviewRequest) Validate() error

type CreateProductShippingClassRequest

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

func (CreateProductShippingClassRequest) Validate

type CreateProductTagRequest

type CreateProductTagRequest = UpsertProductTagRequest

type CreateProductVariationRequest

type CreateProductVariationRequest struct {
	Description    string                             `json:"description,omitempty"`
	SKU            string                             `json:"sku,omitempty"`
	RegularPrice   float64                            `json:"regular_price,string,omitempty"`
	SalePrice      float64                            `json:"sale_price,string,omitempty"`
	Status         string                             `json:"status,omitempty"`
	Virtual        bool                               `json:"virtual,omitempty"`
	Downloadable   bool                               `json:"downloadable,omitempty"`
	Downloads      []entity.ProductDownload           `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  int                                `json:"stock_quantity,omitempty"`
	StockStatus    string                             `json:"stock_status,omitempty"`
	Backorders     string                             `json:"backorders,omitempty"`
	Weight         float64                            `json:"weight,string,omitempty"`
	Dimension      *entity.ProductDimension           `json:"dimensions,omitempty"`
	ShippingClass  string                             `json:"shipping_class,omitempty"`
	Image          *entity.ProductImage               `json:"image,omitempty"`
	Attributes     []entity.ProductVariationAttribute `json:"attributes,omitempty"`
	MenuOrder      int                                `json:"menu_order,omitempty"`
	MetaData       []entity.Meta                      `json:"meta_data,omitempty"`
}

func (CreateProductVariationRequest) Validate

func (m CreateProductVariationRequest) Validate() error

type CreateShippingZoneRequest

type CreateShippingZoneRequest struct {
	Name  string `json:"name"`
	Order int    `json:"order"`
}

func (CreateShippingZoneRequest) Validate

func (m CreateShippingZoneRequest) Validate() error

type CreateTaxClassRequest

type CreateTaxClassRequest struct {
	Name string `json:"name"`
}

func (CreateTaxClassRequest) Validate

func (m CreateTaxClassRequest) Validate() error

type CreateTaxRateRequest

type CreateTaxRateRequest struct {
	Country   string   `json:"country,omitempty"`
	State     string   `json:"state,omitempty"`
	Postcode  string   `json:"postcode,omitempty"`
	City      string   `json:"city,omitempty"`
	Postcodes []string `json:"postcodes,omitempty"`
	Cities    []string `json:"cities,omitempty"`
	Rate      string   `json:"rate,omitempty"`
	Name      string   `json:"name,omitempty"`
	Priority  int      `json:"priority,omitempty"`
	Compound  bool     `json:"compound,omitempty"`
	Shipping  bool     `json:"shipping,omitempty"`
	Order     int      `json:"order,omitempty"`
	Class     string   `json:"class,omitempty"`
}

func (CreateTaxRateRequest) Validate

func (m CreateTaxRateRequest) Validate() error

type CreateWebhookRequest

type CreateWebhookRequest struct {
	Name        string `json:"name,omitempty"`
	Status      string `json:"status,omitempty"`
	Topic       string `json:"topic,omitempty"`
	DeliveryURL string `json:"delivery_url,omitempty"`
	Secret      string `json:"secret,omitempty"`
}

func (CreateWebhookRequest) Validate

func (m CreateWebhookRequest) Validate() error

type CustomersQueryParams

type CustomersQueryParams struct {
	Search  string `url:"search,omitempty"`
	Exclude []int  `url:"exclude,omitempty"`
	Include []int  `url:"include,omitempty"`
	Email   string `url:"email,omitempty"`
	Role    string `url:"role,omitempty"`
	// contains filtered or unexported fields
}

func (*CustomersQueryParams) TidyVars

func (q *CustomersQueryParams) TidyVars() *queryParams

func (CustomersQueryParams) Validate

func (m CustomersQueryParams) Validate() error

type OrderNotesQueryParams

type OrderNotesQueryParams struct {
	Type string `url:"type,omitempty"`
	// contains filtered or unexported fields
}

func (*OrderNotesQueryParams) TidyVars

func (q *OrderNotesQueryParams) TidyVars() *queryParams

func (OrderNotesQueryParams) Validate

func (m OrderNotesQueryParams) Validate() error

type OrderRefundsQueryParams

type OrderRefundsQueryParams struct {
	Search        string `url:"search,omitempty"`
	After         string `url:"after,omitempty"`
	Before        string `url:"before,omitempty"`
	Exclude       []int  `url:"exclude,omitempty"`
	Include       []int  `url:"include,omitempty"`
	Parent        []int  `url:"parent,omitempty"`
	ParentExclude []int  `url:"parent_exclude,omitempty"`
	DecimalPoint  int    `url:"dp,omitempty"`
	// contains filtered or unexported fields
}

func (*OrderRefundsQueryParams) TidyVars

func (q *OrderRefundsQueryParams) TidyVars() *queryParams

func (OrderRefundsQueryParams) Validate

func (m OrderRefundsQueryParams) Validate() error

type OrdersQueryParams

type OrdersQueryParams struct {
	Search        string   `url:"search,omitempty"`
	After         string   `url:"after,omitempty"`
	Before        string   `url:"before,omitempty"`
	Exclude       []int    `url:"exclude,omitempty"`
	Include       []int    `url:"include,omitempty"`
	Parent        []int    `url:"parent,omitempty"`
	ParentExclude []int    `url:"parent_exclude,omitempty"`
	Status        []string `url:"status,omitempty,omitempty"`
	Customer      int      `url:"customer,omitempty"`
	Product       int      `url:"product,omitempty"`
	DecimalPoint  int      `url:"dp,omitempty"`
	// contains filtered or unexported fields
}

func (*OrdersQueryParams) TidyVars

func (q *OrdersQueryParams) TidyVars() *queryParams

func (OrdersQueryParams) Validate

func (m OrdersQueryParams) Validate() error

type ProductAttributeTermsQueryParaTerms

type ProductAttributeTermsQueryParaTerms struct {
	Search    string `url:"search,omitempty"`
	Exclude   []int  `url:"exclude,omitempty"`
	Include   []int  `url:"include,omitempty"`
	HideEmpty bool   `url:"hide_empty,omitempty"`
	Parent    int    `url:"parent,omitempty"`
	Product   int    `url:"product,omitempty"`
	Slug      string `url:"slug,omitempty"`
	// contains filtered or unexported fields
}

func (*ProductAttributeTermsQueryParaTerms) TidyVars

func (q *ProductAttributeTermsQueryParaTerms) TidyVars() *queryParams

func (ProductAttributeTermsQueryParaTerms) Validate

type ProductAttributesQueryParams

type ProductAttributesQueryParams struct {
	// contains filtered or unexported fields
}

func (*ProductAttributesQueryParams) TidyVars

func (q *ProductAttributesQueryParams) TidyVars() *queryParams

func (ProductAttributesQueryParams) Validate

func (m ProductAttributesQueryParams) Validate() error

type ProductCategoriesQueryParams

type ProductCategoriesQueryParams struct {
	Search    string `url:"search,omitempty"`
	Exclude   []int  `url:"exclude,omitempty"`
	Include   []int  `url:"include,omitempty"`
	HideEmpty bool   `url:"hide_empty,omitempty"`
	Parent    int    `url:"parent,omitempty"`
	Product   int    `url:"product,omitempty"`
	Slug      string `url:"slug,omitempty"`
	// contains filtered or unexported fields
}

func (*ProductCategoriesQueryParams) TidyVars

func (q *ProductCategoriesQueryParams) TidyVars() *queryParams

func (ProductCategoriesQueryParams) Validate

func (m ProductCategoriesQueryParams) Validate() error

type ProductReviewsQueryParams

type ProductReviewsQueryParams struct {
	Search          string   `url:"search,omitempty"`
	After           string   `url:"after,omitempty"`
	Before          string   `url:"before,omitempty"`
	Exclude         []int    `url:"exclude,omitempty"`
	Include         []int    `url:"include,omitempty"`
	Reviewer        []int    `url:"reviewer,omitempty"`
	ReviewerExclude []int    `url:"reviewer_exclude,omitempty"`
	ReviewerEmail   []string `url:"reviewer_email,omitempty"`
	Product         []int    `url:"product,omitempty"`
	Status          string   `url:"status,omitempty"`
	// contains filtered or unexported fields
}

func (*ProductReviewsQueryParams) TidyVars

func (q *ProductReviewsQueryParams) TidyVars() *queryParams

func (ProductReviewsQueryParams) Validate

func (m ProductReviewsQueryParams) Validate() error

type ProductShippingClassesQueryParams

type ProductShippingClassesQueryParams struct {
	Search    string `url:"search,omitempty"`
	Exclude   []int  `url:"exclude,omitempty"`
	Include   []int  `url:"include,omitempty"`
	HideEmpty bool   `url:"hide_empty,omitempty"`
	Parent    int    `url:"parent,omitempty"`
	Product   int    `url:"product,omitempty"`
	Slug      string `url:"slug,omitempty"`
	// contains filtered or unexported fields
}

func (*ProductShippingClassesQueryParams) TidyVars

func (q *ProductShippingClassesQueryParams) TidyVars() *queryParams

func (ProductShippingClassesQueryParams) Validate

type ProductTagsQueryParams

type ProductTagsQueryParams struct {
	Search    string `url:"search,omitempty"`
	Exclude   []int  `url:"exclude,omitempty"`
	Include   []int  `url:"include,omitempty"`
	HideEmpty bool   `url:"hide_empty,omitempty"`
	Product   int    `url:"product,omitempty"`
	Slug      string `url:"slug,omitempty"`
	// contains filtered or unexported fields
}

func (*ProductTagsQueryParams) TidyVars

func (q *ProductTagsQueryParams) TidyVars() *queryParams

func (ProductTagsQueryParams) Validate

func (m ProductTagsQueryParams) Validate() error

type ProductVariationsQueryParams

type ProductVariationsQueryParams struct {
	Search        string  `url:"search,omitempty"`
	After         string  `url:"after,omitempty"`
	Before        string  `url:"before,omitempty"`
	Exclude       []int   `url:"exclude,omitempty"`
	Include       []int   `url:"include,omitempty"`
	Parent        []int   `url:"parent,omitempty"`
	ParentExclude []int   `url:"parent_exclude,omitempty"`
	Slug          string  `url:"slug,omitempty"`
	Status        string  `url:"status,omitempty"`
	SKU           string  `url:"sku,omitempty"`
	TaxClass      string  `url:"tax_class,omitempty"`
	OnSale        string  `url:"on_sale,omitempty"`
	MinPrice      float64 `url:"min_price,omitempty"`
	MaxPrice      float64 `url:"max_price,omitempty"`
	StockStatus   string  `url:"stock_status,omitempty"`
	// contains filtered or unexported fields
}

func (*ProductVariationsQueryParams) TidyVars

func (q *ProductVariationsQueryParams) TidyVars() *queryParams

func (ProductVariationsQueryParams) Validate

func (m ProductVariationsQueryParams) Validate() error

type ProductsQueryParams

type ProductsQueryParams struct {
	Search        string  `url:"search,omitempty"`
	After         string  `url:"after,omitempty"`
	Before        string  `url:"before,omitempty"`
	Exclude       []int   `url:"exclude,omitempty"`
	Include       []int   `url:"include,omitempty"`
	Parent        []int   `url:"parent,omitempty"`
	ParentExclude []int   `url:"parent_exclude,omitempty"`
	Slug          string  `url:"slug,omitempty"`
	Status        string  `url:"status,omitempty"`
	Type          string  `url:"type,omitempty"`
	SKU           string  `url:"sku,omitempty"`
	Featured      bool    `url:"featured,omitempty"`
	Category      string  `url:"category,omitempty"`
	Tag           string  `url:"tag,omitempty"`
	ShippingClass string  `url:"shipping_class,omitempty"`
	Attribute     string  `url:"attribute,omitempty"`
	AttributeTerm string  `url:"attribute_term,omitempty"`
	TaxClass      string  `url:"tax_class,omitempty"`
	OnSale        bool    `url:"on_sale,omitempty"`
	MinPrice      float64 `url:"min_price,string,omitempty"`
	MaxPrice      float64 `url:"max_price,string,omitempty"`
	StockStatus   string  `url:"stock_status,omitempty"`
	// contains filtered or unexported fields
}

func (*ProductsQueryParams) TidyVars

func (q *ProductsQueryParams) TidyVars() *queryParams

func (ProductsQueryParams) Validate

func (m ProductsQueryParams) Validate() error

type ReportsQueryParams

type ReportsQueryParams struct {
	Context string `url:"context,omitempty"`
	Period  string `url:"period,omitempty"`
	DateMin string `url:"date_min,omitempty"`
	DateMax string `url:"date_max,omitempty"`
}

func (ReportsQueryParams) Validate

func (m ReportsQueryParams) Validate() error

type SalesReportsQueryParams

type SalesReportsQueryParams = ReportsQueryParams

type ShippingZoneMethodIncludeRequest

type ShippingZoneMethodIncludeRequest struct {
	MethodId string `json:"method_id"`
}

func (ShippingZoneMethodIncludeRequest) Validate

type TaxRatesQueryParams

type TaxRatesQueryParams struct {
	Class string `url:"class,omitempty"`
	// contains filtered or unexported fields
}

func (*TaxRatesQueryParams) TidyVars

func (q *TaxRatesQueryParams) TidyVars() *queryParams

func (TaxRatesQueryParams) Validate

func (m TaxRatesQueryParams) Validate() error

type TopSellerReportsQueryParams

type TopSellerReportsQueryParams = SalesReportsQueryParams

type UpdateCouponRequest

type UpdateCouponRequest struct {
	Code             string  `json:"code,omitempty"`
	DiscountType     string  `json:"discount_type,omitempty"`
	Amount           float64 `json:"amount,omitempty,string"`
	IndividualUse    bool    `json:"individual_use,omitempty"`
	ExcludeSaleItems bool    `json:"exclude_sale_items,omitempty"`
	MinimumAmount    float64 `json:"minimum_amount,omitempty,string"`
}

func (UpdateCouponRequest) Validate

func (m UpdateCouponRequest) Validate() error

type UpdateCustomerRequest

type UpdateCustomerRequest struct {
	Email     string            `json:"email,omitempty"`
	FirstName string            `json:"first_name,omitempty"`
	LastName  string            `json:"last_name,omitempty"`
	Billing   *entity.Billing   `json:"billing,omitempty"`
	Shipping  *entity.Shipping  `json:"shipping,omitempty"`
	MetaData  []entity.MetaData `json:"meta_data,omitempty"`
}

func (UpdateCustomerRequest) Validate

func (m UpdateCustomerRequest) Validate() error

type UpdateOrderRequest

type UpdateOrderRequest = CreateOrderRequest

type UpdatePaymentGatewayRequest

type UpdatePaymentGatewayRequest struct {
	Title             string                                  `json:"title,omitempty"`
	Description       string                                  `json:"description,omitempty"`
	Order             int                                     `json:"order,omitempty"`
	Enabled           bool                                    `json:"enabled,omitempty"`
	MethodTitle       string                                  `json:"method_title,omitempty"`
	MethodDescription string                                  `json:"method_description,omitempty"`
	MethodSupports    []string                                `json:"method_supports,omitempty"`
	Settings          map[string]entity.PaymentGatewaySetting `json:"settings,omitempty"`
}

func (UpdatePaymentGatewayRequest) Validate

func (m UpdatePaymentGatewayRequest) Validate() error

type UpdateProductAttributeRequest

type UpdateProductAttributeRequest = CreateProductAttributeRequest

type UpdateProductAttributeTermRequest

type UpdateProductAttributeTermRequest = CreateProductAttributeTermRequest

type UpdateProductCategoryRequest

type UpdateProductCategoryRequest = UpsertProductCategoryRequest

type UpdateProductRequest

type UpdateProductRequest = CreateProductRequest

type UpdateProductReviewRequest

type UpdateProductReviewRequest = CreateProductReviewRequest

type UpdateProductShippingClassRequest

type UpdateProductShippingClassRequest = CreateProductShippingClassRequest

type UpdateProductTagRequest

type UpdateProductTagRequest = UpsertProductTagRequest

type UpdateProductVariationRequest

type UpdateProductVariationRequest = CreateProductVariationRequest

type UpdateSettingOptionRequest

type UpdateSettingOptionRequest struct {
	Value string `json:"value"`
}

func (UpdateSettingOptionRequest) Validate

func (m UpdateSettingOptionRequest) Validate() error

type UpdateShippingZoneLocationsRequest

type UpdateShippingZoneLocationsRequest []entity.ShippingZoneLocation

func (UpdateShippingZoneLocationsRequest) Validate

type UpdateShippingZoneMethodRequest

type UpdateShippingZoneMethodRequest struct {
	Order    int                             `json:"order"`
	Enabled  bool                            `json:"enabled"`
	Settings UpdateShippingZoneMethodSetting `json:"settings"`
}

func (UpdateShippingZoneMethodRequest) Validate

type UpdateShippingZoneMethodSetting

type UpdateShippingZoneMethodSetting struct {
	Value string `json:"value"`
}

type UpdateShippingZoneRequest

type UpdateShippingZoneRequest = CreateShippingZoneRequest

type UpdateTaxRateRequest

type UpdateTaxRateRequest = CreateTaxRateRequest

type UpdateWebhookRequest

type UpdateWebhookRequest = CreateWebhookRequest

type UpsertProductCategoryRequest

type UpsertProductCategoryRequest struct {
	Name        string               `json:"name"`
	Slug        string               `json:"slug,omitempty"`
	Parent      int                  `json:"parent,omitempty"`
	Description string               `json:"description,omitempty"`
	Display     string               `json:"display,omitempty"`
	Image       *entity.ProductImage `json:"image,omitempty"`
	MenuOrder   int                  `json:"menu_order,omitempty"`
}

func (UpsertProductCategoryRequest) Validate

func (m UpsertProductCategoryRequest) Validate() error

type UpsertProductTagRequest

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

func (UpsertProductTagRequest) Validate

func (m UpsertProductTagRequest) Validate() error

type WebhooksQueryParams

type WebhooksQueryParams struct {
	Search  string `url:"search"`
	After   string `url:"after"`
	Before  string `url:"before"`
	Exclude []int  `url:"exclude"`
	Include []int  `url:"include"`
	Status  string `url:"status"`
	// contains filtered or unexported fields
}

func (*WebhooksQueryParams) TidyVars

func (q *WebhooksQueryParams) TidyVars() *queryParams

func (WebhooksQueryParams) Validate

func (m WebhooksQueryParams) Validate() error

type WooCommerce

type WooCommerce struct {
	Debug    bool        // Is debug mode
	Logger   *log.Logger // Log
	Services services    // WooCommerce API services
}

func NewClient

func NewClient(config config.Config) *WooCommerce

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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