Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: Php variants insert error

Solved

Php variants insert error

SCoccia
Tourist
6 1 4

Hi, I try to create a php file to insert product to shopify, I try to use 2023-4 but I receive a error

Parse error: syntax error, unexpected token "{", expecting "]" in /var/www/vhosts/mysite/Shopify/verify.php on line 24

 

$response = $client->post(
"products",
[
"product" => [
"title" => "Giacca Uomo 2 Bottoni",
"body_html" => "<strong>Giacca Uomo 2 Bottoni</strong>",
"vendor" => "7Concept",
"product_type" => "Abiti",
"variants" => [{"option1"=>"58", "price"=>"199.00", "sku"=>"123"},{"option1"=>"56", "price"=>"199.00", "sku"=>"124"}],
],
]
);

 

the problem is to:

"variants" => [{"option1"=>"58", "price"=>"199.00", "sku"=>"123"},{"option1"=>"56", "price"=>"199.00", "sku"=>"124"}],
],

 

not acept "[" why?

 

 

 

 

Accepted Solution (1)

SCoccia
Tourist
6 1 4

This is an accepted solution.

Resolved... I need replace { with  [

 

from 

"variants" => [{"option1"=>"58", "price"=>"199.00", "sku"=>"123"},{"option1"=>"56", "price"=>"199.00", "sku"=>"124"}],

 

to

"variants" => [["option1"=>"58", "price"=>"199.00", "sku"=>"123"],["option1"=>"56", "price"=>"199.00", "sku"=>"124"]],

View solution in original post

Reply 1 (1)

SCoccia
Tourist
6 1 4

This is an accepted solution.

Resolved... I need replace { with  [

 

from 

"variants" => [{"option1"=>"58", "price"=>"199.00", "sku"=>"123"},{"option1"=>"56", "price"=>"199.00", "sku"=>"124"}],

 

to

"variants" => [["option1"=>"58", "price"=>"199.00", "sku"=>"123"],["option1"=>"56", "price"=>"199.00", "sku"=>"124"]],