@robinpath/woocommerce
0.1.1Node.jsPublicWooCommerce module for RobinPath.
WooCommerce
WooCommerce module for RobinPath.
Package: @robinpath/woocommerce | Category: Ecommerce | Type: Integration
Authentication
woocommerce.setCredentials "your-credentials"
Call this once at the start of your script before using any other function. Credentials persist for the duration of the script execution.
Use Cases
Use the woocommerce module when you need to:
- listProducts -- Use
woocommerce.listProductsto perform this operation - getProduct -- Use
woocommerce.getProductto perform this operation - createProduct -- Use
woocommerce.createProductto perform this operation - updateProduct -- Use
woocommerce.updateProductto perform this operation - deleteProduct -- Use
woocommerce.deleteProductto perform this operation
Quick Reference
| Function | Description | Returns |
|---|---|---|
setCredentials | Configure woocommerce credentials. | object |
listProducts | listProducts | object |
getProduct | getProduct | object |
createProduct | createProduct | object |
updateProduct | updateProduct | object |
deleteProduct | deleteProduct | object |
listOrders | listOrders | object |
getOrder | getOrder | object |
createOrder | createOrder | object |
updateOrder | updateOrder | object |
deleteOrder | deleteOrder | object |
listCustomers | listCustomers | object |
getCustomer | getCustomer | object |
createCustomer | createCustomer | object |
updateCustomer | updateCustomer | object |
listCategories | listCategories | object |
createCategory | createCategory | object |
listCoupons | listCoupons | object |
createCoupon | createCoupon | object |
getOrderNotes | getOrderNotes | object |
createOrderNote | createOrderNote | object |
getReport | getReport | object |
listShipping | listShipping | object |
Functions
setCredentials
Configure woocommerce credentials.
Module: woocommerce | Returns: object -- API response.
woocommerce.setCredentials
| Parameter | Type | Required | Description |
|---|---|---|---|
siteUrl | string | Yes | siteUrl |
consumerKey | string | Yes | consumerKey |
consumerSecret | string | Yes | consumerSecret |
listProducts
listProducts
Module: woocommerce | Returns: object -- API response.
woocommerce.listProducts
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getProduct
getProduct
Module: woocommerce | Returns: object -- API response.
woocommerce.getProduct
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
createProduct
createProduct
Module: woocommerce | Returns: object -- API response.
woocommerce.createProduct
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
updateProduct
updateProduct
Module: woocommerce | Returns: object -- API response.
woocommerce.updateProduct
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
deleteProduct
deleteProduct
Module: woocommerce | Returns: object -- API response.
woocommerce.deleteProduct
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
listOrders
listOrders
Module: woocommerce | Returns: object -- API response.
woocommerce.listOrders
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getOrder
getOrder
Module: woocommerce | Returns: object -- API response.
woocommerce.getOrder
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
createOrder
createOrder
Module: woocommerce | Returns: object -- API response.
woocommerce.createOrder
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
updateOrder
updateOrder
Module: woocommerce | Returns: object -- API response.
woocommerce.updateOrder
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
deleteOrder
deleteOrder
Module: woocommerce | Returns: object -- API response.
woocommerce.deleteOrder
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
listCustomers
listCustomers
Module: woocommerce | Returns: object -- API response.
woocommerce.listCustomers
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getCustomer
getCustomer
Module: woocommerce | Returns: object -- API response.
woocommerce.getCustomer
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
createCustomer
createCustomer
Module: woocommerce | Returns: object -- API response.
woocommerce.createCustomer
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
updateCustomer
updateCustomer
Module: woocommerce | Returns: object -- API response.
woocommerce.updateCustomer
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
listCategories
listCategories
Module: woocommerce | Returns: object -- API response.
woocommerce.listCategories
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
createCategory
createCategory
Module: woocommerce | Returns: object -- API response.
woocommerce.createCategory
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
listCoupons
listCoupons
Module: woocommerce | Returns: object -- API response.
woocommerce.listCoupons
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
createCoupon
createCoupon
Module: woocommerce | Returns: object -- API response.
woocommerce.createCoupon
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getOrderNotes
getOrderNotes
Module: woocommerce | Returns: object -- API response.
woocommerce.getOrderNotes
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
createOrderNote
createOrderNote
Module: woocommerce | Returns: object -- API response.
woocommerce.createOrderNote
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getReport
getReport
Module: woocommerce | Returns: object -- API response.
woocommerce.getReport
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
listShipping
listShipping
Module: woocommerce | Returns: object -- API response.
woocommerce.listShipping
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
Error Handling
All functions throw on failure. Common errors:
| Error | Cause |
|---|---|
Woocommerce API error (${res.status}): ${t} | Check the error message for details |
woocommerce.setCredentials requires siteUrl, consumerKey, consumerSecret. | Check the error message for details |
woocommerce.updateProduct requires an ID. | Check the error message for details |
woocommerce.deleteProduct requires an ID. | Check the error message for details |
woocommerce.updateOrder requires an ID. | Check the error message for details |
woocommerce.deleteOrder requires an ID. | Check the error message for details |
woocommerce.updateCustomer requires an ID. | Check the error message for details |
Woocommerce: "..." not configured. Call woocommerce.setCredentials first. | Check the error message for details |
@desc "List products and validate result"
do
set $result as woocommerce.listProducts
if $result != null
print "Success"
else
print "No result"
end
enddo
Recipes
1. List and iterate Products
Retrieve all items and loop through them.
@desc "Setup authentication"
do
woocommerce.setCredentials $token
enddo
@desc "List products and iterate results"
do
set $result as woocommerce.listProducts
each $item in $result
print $item
end
enddo
2. Create a new item with createProduct
Create a new resource and capture the result.
@desc "Setup authentication"
do
woocommerce.setCredentials $token
enddo
@desc "Create product"
do
set $result as woocommerce.createProduct
print "Created: " + $result
enddo
3. Create and update workflow
Create an item and then update it.
@desc "Setup authentication"
do
woocommerce.setCredentials $token
enddo
@desc "Create product and update product"
do
set $created as woocommerce.createProduct
# Update the created item
woocommerce.updateProduct
enddo
4. Check before creating
List existing items and only create if needed.
@desc "Setup authentication"
do
woocommerce.setCredentials $token
enddo
@desc "List products and create product"
do
set $existing as woocommerce.listProducts
if $existing == null
woocommerce.createProduct
print "Item created"
else
print "Item already exists"
end
enddo
5. Multi-step WooCommerce workflow
Chain multiple woocommerce operations together.
@desc "Setup authentication"
do
woocommerce.setCredentials $token
enddo
@desc "List products, get product, and more"
do
set $r_listProducts as woocommerce.listProducts
set $r_getProduct as woocommerce.getProduct
set $r_createProduct as woocommerce.createProduct
print "All operations complete"
enddo
6. Safe listProducts with validation
Check results before proceeding.
@desc "Setup authentication"
do
woocommerce.setCredentials $token
enddo
@desc "List products and validate result"
do
set $result as woocommerce.listProducts
if $result != null
print "Success: " + $result
else
print "Operation returned no data"
end
enddo
Related Modules
- shopify -- Shopify module for complementary functionality
- bigcommerce -- BigCommerce module for complementary functionality
- square -- Square module for complementary functionality
- json -- JSON module for complementary functionality
Versions (1)
| Version | Tag | Published |
|---|---|---|
| 0.1.1 | latest | 1 months ago |
$ robinpath add @robinpath/woocommerce
