Documentation ¶
Index ¶
- type WooAttribute
- type WooBatchPostRequest
- type WooCategory
- type WooCategoryLink
- type WooCategoryLinks
- type WooConnection
- func (w *WooConnection) ExecuteRequestQueue(strict, verbose bool) ([][]byte, error)
- func (w *WooConnection) GetAllProducts(verbose bool) ([]WooProduct, error)
- func (w *WooConnection) Init(domain, key, secret string, ...) error
- func (w *WooConnection) PurgeProducts(verbose bool) error
- func (w *WooConnection) PushToQueue(r WooRequest)
- func (w *WooConnection) QueryCategories(searchString string) ([]WooCategory, error)
- func (w *WooConnection) Request(method, endpoint string, body []byte) ([]byte, error)
- func (w *WooConnection) ViewRequestQueue() ([][]byte, error)
- type WooDimension
- type WooGetRequest
- type WooImage
- type WooItem
- type WooPostRequest
- type WooProduct
- type WooRequest
- type WooTag
- type WpmlPrice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type WooAttribute ¶
type WooAttribute struct { ID int32 `json:"id,omitempty"` Name string `json:"name,omitempty"` Option string `json:"option,omitempty"` // "term" Options []string `json:"options,omitempty"` // "terms" Slug string `json:"slug,omitempty"` Visible bool `json:"visible,omitempty"` Type string `json:"type,omitempty"` // "select" by default }
WooAttribute provides additional general fields for the products
type WooBatchPostRequest ¶
type WooBatchPostRequest struct { Endpoint string `json:"-"` Create []WooItem `json:"create,omitempty"` // Create requests must not have IDs -the WC backend will generate them Update []WooItem `json:"update,omitempty"` // Update requests must have IDs Delete []int `json:"delete,omitempty"` // Delete requests can only be IDs }
WooBatchPostRequest sends a payload of batch creations, updates and/or deletions
func (WooBatchPostRequest) Send ¶
func (b WooBatchPostRequest) Send(w *WooConnection) ([]byte, error)
Send implements the WooRequest Interface
type WooCategory ¶
type WooCategory struct { ID int32 `json:"id,omitempty"` Name string `json:"name"` Alt string `json:"alt,omitempty"` Slug string `json:"slug,omitempty"` Parent int32 `json:"parent,omitempty"` Description string `json:"description,omitempty"` Image WooImage `json:"image,omitempty"` MenuOrder int32 `json:"menu_order,omitempty"` Count int32 `json:"count,omitempty"` Links WooCategoryLinks `json:"_links,omitempty"` // read-only }
WooCategory convers objects relating to the WC Category tree
type WooCategoryLink ¶
type WooCategoryLink struct {
Href string `json:"href,omitempty"`
}
WooCategoryLink can be either self, collection, or up e.g.: "https://example.com/wp-json/wc/v3/products/categories/15"
type WooCategoryLinks ¶
type WooCategoryLinks struct { Self []WooCategoryLink `json:"self,omitempty"` Collection []WooCategoryLink `json:"collection,omitempty"` Up []WooCategoryLink `json:"up,omitempty"` }
WooCategoryLinks are generated from the category ids: e.g.: "href": "https://example.com/wp-json/wc/v3/products/categories/15"
type WooConnection ¶
type WooConnection struct {
// contains filtered or unexported fields
}
WooConnection interfaces with the WooCommerce backend
func (*WooConnection) ExecuteRequestQueue ¶
func (w *WooConnection) ExecuteRequestQueue(strict, verbose bool) ([][]byte, error)
ExecuteRequestQueue executes all the request that were pushed before and returns an array of the raw responses as bytes if strict: returns on any error; else: finishes regardless of errors
func (*WooConnection) GetAllProducts ¶
func (w *WooConnection) GetAllProducts(verbose bool) ([]WooProduct, error)
GetAllProducts returns all products from the WC backend
func (*WooConnection) Init ¶
func (w *WooConnection) Init(domain, key, secret string, productsPerBatch, maxConcurrentRequests, maxRetries int) error
Init takes in the credentials before dong any other operation
func (*WooConnection) PurgeProducts ¶
func (w *WooConnection) PurgeProducts(verbose bool) error
PurgeProducts deletes all the products from the woo commerce backend Remember: Does not remove the image assets from the server!
func (*WooConnection) PushToQueue ¶
func (w *WooConnection) PushToQueue(r WooRequest)
PushToQueue appends a WooREquest to the queue to later be executed
func (*WooConnection) QueryCategories ¶
func (w *WooConnection) QueryCategories(searchString string) ([]WooCategory, error)
QueryCategories returns all categories from the WC backend https://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-product-categories
func (*WooConnection) Request ¶
func (w *WooConnection) Request(method, endpoint string, body []byte) ([]byte, error)
Request sends a request: ("GET", "POST"), endpoint, body
func (*WooConnection) ViewRequestQueue ¶
func (w *WooConnection) ViewRequestQueue() ([][]byte, error)
ViewRequestQueue returns the marshalled requests as they will be sent by ExecuteRequestQueue
type WooDimension ¶
type WooDimension struct { Length string `json:"length,omitempty"` Width string `json:"width,omitempty"` Height string `json:"height,omitempty"` }
WooDimension stores length, width, and height
type WooGetRequest ¶
type WooGetRequest struct {
Endpoint string
}
WooGetRequest implements GET request via a WooConnection
func (WooGetRequest) Send ¶
func (g WooGetRequest) Send(w *WooConnection) ([]byte, error)
Send implementes the WooRequest interface
type WooImage ¶
type WooImage struct { ID int32 `json:"id,omitempty"` //DateCreated string `json:"date_created,omitempty"` DateCreatedGMT string `json:"date_created_gmt,omitempty"` //DateModified string `json:"date_modified,omitempty"` DateModifiedGMT string `json:"date_modified_gmt,omitempty"` SRC string `json:"src,omitempty"` Name string `json:"name,omitempty"` Alt string `json:"alt,omitempty"` }
WooImage contains all the information on product images
type WooItem ¶
type WooItem interface {
GetID() int32
}
WooItem is the object used to hold requests and responses towards the woocommerce api Examples: WooProduct, WooAttribute, WooCategory
type WooPostRequest ¶
WooPostRequest can be used for synchronous requests to the products, attributes, or categories endpoint
func (WooPostRequest) Send ¶
func (p WooPostRequest) Send(w *WooConnection) ([]byte, error)
Send implements the WooRequest interface
type WooProduct ¶
type WooProduct struct { ID uint32 `json:"id,omitempty"` // read-only!!! //Key uint32 `json:"-"` SKU string `json:"sku,omitempty"` Name string `json:"name,omitempty"` Slug string `json:"slug,omitempty"` Permalink string `json:"permalink,omitempty"` // read-only //DateCreated string `json:"date_created,omitempty"` // read-only DateCreatedGmt string `json:"date_created_gmt,omitempty"` // read-only //DateModified string `json:"date_modified,omitempty"` // read-only DateModifiedGmt string `json:"date_modified_gmt,omitempty"` // read-only Type string `json:"type,omitempty"` Status string `json:"status,omitempty"` Featured bool `json:"featured,omitempty"` CatalogVisibility string `json:"catalog_visibility,omitempty"` // Options: visible, catalog, search and hidden. Default is visible. Description string `json:"description,omitempty"` ShortDescription string `json:"short_description,omitempty"` //Price string `json:"price,omitempty"` // read-only RegularPrice string `json:"regular_price,omitempty"` SalePrice string `json:"sale_price,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"` //PriceHTML string `json:"price_html,omitempty"` // read-only OnSale bool `json:"on_sale,omitempty"` // read-only //Purchasable bool `json:"purchasable,omitempty"` // read-only TotalSales int32 `json:"total_sales,omitempty"` // read-only ExternalURL string `json:"external_url,omitempty"` // real outlink ButtonText string `json:"button_text,omitempty"` // external shop to link to TaxStatus string `json:"tax_status,omitempty"` // Options: taxable, shipping and none. Default is taxable TaxClass string `json:"tax_class,omitempty"` StockQuantity int32 `json:"stock_quantity,omitempty"` StockStatus string `json:"stock_status,omitempty"` // Options: instock, outofstock, onbackorder. Default is instock. SoldIndividually bool `json:"sold_individually,omitempty"` // Allow one item to be bought in a single order. Default is false Weight string `json:"weight,omitempty"` Dimensions WooDimension `json:"dimensions,omitempty"` ShippingRequired bool `json:"shipping_required,omitempty"` // read-only ReviewsAllowed bool `json:"reviews_allowed,omitempty"` // default: true AverageRating string `json:"average_rating,omitempty"` // read-only RatingCount int32 `json:"rating_count,omitempty"` // read-only RelatedIds []int32 `json:"related_ids,omitempty"` // read_only UpsellIds []int32 `json:"upsell_ids,omitempty"` CrossSellIds []int32 `json:"cross_sell_ids,omitempty"` ParentID int32 `json:"parent_id,omitempty"` Categories []WooCategory `json:"categories,omitempty"` Tags []WooTag `json:"tags,omitempty"` Images []WooImage `json:"images,omitempty"` DefaultAttributes []map[string]interface{} `json:"default_attributes,omitempty"` Variations []string `json:"variations,omitempty"` GroupedProducts []int32 `json:"grouped_products,omitempty"` MenuOrder int32 `json:"menu_order,omitempty"` MetaData []map[string]interface{} `json:"meta_data,omitempty"` Attributes []WooAttribute `json:"attributes,omitempty"` Brands []interface{} `json:"brands,omitempty"` Language string `json:"language,omitempty"` Lang string `json:"lang,omitempty"` // relates to the woocommerce multilingual package; otherwise: omit! CustomPrices map[string]WpmlPrice `json:"custom_prices,omitempty"` // "custom_prices": {"EUR": {"regular_price": 100, "sale_price": 99}} }
WooProduct is the struct through which you interface with the WooCommerce backend
type WooRequest ¶
type WooRequest interface {
Send(w *WooConnection) ([]byte, error)
}
WooRequest is implemented for Batch/Post and Get