Creating multiple metaphones with a different key showing an error

I want to create several meta fields with a different key, but it shows me the following error:

'metafield' => 'expected array as 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); 
+8
json string arrays php shopify
source share
2 answers

If you add metafiles with a new entry, you can pass an array of metafiles. Otherwise, you will have to create them one at a time url '/admin/variant/#id/metafields.json

Your value 'C' is not an integer. I suspect that the quote '0' will also fail. This probably throws the first mistake. Do you mean 0 or 0xC?

+1
source share

Remove the comma from the key

 'value_type'=>integer,), 

as

 'value_type'=>integer), 
0
source share

All Articles