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);
From your Shopify admin, go to Settings > Metafields. Select the part of your store that you want to add a metafield to. For example, Products. Click Add definition.
Together, the namespace and key create a unique identifier for your metafield. They're separated by a . , and can only contain letters, numbers, underscores ( _ ), and hyphens ( - ). You can use a namespace to group similar metafields together, but each namespace and key combination must be unique.
Metafields enable you to customize the functionality and appearance of your Shopify store by letting you save specialized information that isn't usually captured in the Shopify admin. You can use Metafields for internal tracking, or to display specialized information on your online store in a variety of ways.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With