Skip to content

Instantly share code, notes, and snippets.

@joshubrown
Created August 7, 2015 17:04
Show Gist options
  • Save joshubrown/acafd57ba3fe36756e97 to your computer and use it in GitHub Desktop.
Save joshubrown/acafd57ba3fe36756e97 to your computer and use it in GitHub Desktop.
Creating a product variant using PHP
<?php
$ch = curl_init("https://key:pass@appsrule.myshopify.com/admin/products/1075339140/variants.json");
$variant = json_encode(array('variant'=> array('option1' => 'test')));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $variant);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$response = curl_exec($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment