diff --git a/README.md b/README.md index 332e93d..63dfba3 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,51 @@ if err != nil { } ``` +## Create a variant to a product + +If you want to create a new variant, you can do so using the following function. The ID of the main product is required. + +You can find the description from Shopify [here](https://shopify.dev/api/admin-rest/2021-07/resources/product-variant#[post]/admin/api/2021-07/products/{product_id}/variants.json). + +```go +// Define request +r := goshopify.Request{ + ApiKey: "", + ApiPassword: "", + StoreName: "", +} + +// Define body +body := ProductVariantBody{ + ProductVariantBodyVariant{ + Title: "Testartikel", + Price: "24,99", + Sku: "21481462121", + CompareAtPrice: "48,99", + FulfillmentService: "manual", + InventoryManagement: "shopify", + Option1: "42", + Option2: "", + Option3: "", + Taxable: true, + Barcode: "", + Grams: 0, + Weight: 0, + WeightUnit: "", + InventoryQuantity: 0, + RequiresShipping: true, + }, +} + +// Create a product variant +variant, err := goshopify.AddProductVariant(6917353078968, body, r) +if err != nil { + fmt.Println(err) +} else { + fmt.Println(variant) +} +``` + ## Get list of orders since id To get a list of orders, you can call the following function. The list shows all orders by a certain ID, if you leave this ID at 0, then the orders are displayed from the beginning. 200 orders are always read out at once.