I want to Create multiple Meta fields with different key but it displaying me following error:
‘metafield’ => ‘expected Array to be a Hash’,
This is my code:
$prodcut_variant = array(
'metafield'=>array(
array('namespace'=>'orbital_response',
'key'=>'Os Purchases',
'value'=>'0',
'value_type'=>integer,),
array('namespace'=>'orbital_response',
'key'=>'Stock Status',
'value'=>'C',
'value_type'=>integer,)
));
$request_update = $shopify('POST /admin/products/{#ID}/metafields.json',array(),$prodcut_variant);
2
Answers
Remove the comma from key
like as
If you are adding metafields with a new record you can pass an array of metafields. Otherwise you have to create them one at a time at the url ‘/admin/variant/#id/metafields.json
Your value ‘C’ is not an integer. I suspect the quoted ‘0’ won’t go through either. It is likely these that are throwing the first error. Do you mean 0 or 0xC?