(PHP - API REST) Problem With Multi-Variant And Multi-Option Product

(PHP - API REST) Problem With Multi-Variant And Multi-Option Product

LeoDea
Shopify Partner
7 0 1

I am trying to create a REST API based connection via PHP to create a product with multiple variations and multiple options but I cannot find a solution. I tried to run the code found in the documentation using the proposed shopify-php-api library but the PHP interpreter gives me the following error: "Parse error: syntax error, unexpected token "{", expecting "]"".

I also created a procedure with an associative array and the http_build_query function using curl for creating the API request. With this method I was able to handle a GET call of products and update an inventory of a specific variant but I am unable to create multi-variant and multi-option products.

 

Thank you in advance who will answer me!

 

Greetings

 

This is the code:

 

$prodotto= array();
$prodotto['product']['title']="TEST";
$prodotto['product']['variants'][0]['option1']="Nero";
$prodotto['product']['variants'][0]['option2']="35";
$prodotto['product']['variants'][1]['option1']="Blu";
$prodotto['product']['variants'][1]['option2']="36";
$prodotto['product']['options'][0]['name']="Colore";
$prodotto['product']['options'][0]['values'][0]="Nero";
$prodotto['product']['options'][0]['values'][1]="Blu";
$prodotto['product']['options'][1]['name']="Taglia";
$prodotto['product']['options'][1]['values'][0]="35";
$prodotto['product']['options'][1]['values'][1]="36";

Replies 2 (2)

IP1999
Shopify Partner
118 8 13

@LeoDea is this question still relevant? Did you ever solve this?

LeoDea
Shopify Partner
7 0 1

Hi @IP1999, The question is still relevant. I have never been able to solve the problem.