Hello Shopfiy开发人员!
我通过API调用遇到了notes属性的问题。它曾经工作到一个月前,然后事情开始侧身。有没有改变语法?这是我的代码片段,它在for循环中返回错误。
错误消息“未定义的索引:在foreach行的note_attribute”
// Overwrite custom status field if it's defined in note-attributes
if(array_key_exists('note-attributes', $o))
{
// For whatever reason, the note-attributes are formatted
// differently if there's only one key => value pair
// ( * see examples at end of this file )
// If the note-attribute array has the key 'name' in it, it's just a single pair.
// Otherwise, the note-attribute array would be numerically indexed with keys 0,1,2.. etc
if(array_key_exists('name',$o['note-attributes']['note_attribute']))
{
if($o['note-attributes']['note_attribute']['name'] == "custom_status")
$arr_tmp[7] = $o['note-attributes']['note_attribute']['value'] ;
}
else
{
foreach($o['note-attributes']['note_attribute'] as $na) //Fails here
{
if($na['name'] == "custom_status")
$arr_tmp[7] = $na['value'] ;
}
}
}
非常感谢您的帮助。谢谢。
答案 0 :(得分:1)
这里的问题是由于XML节点语法的变化; Shopify的回复在响应中已更改为note-attributes
到note_attributes
,并且已将其更改回来。