您好,购物开发人员!
我在通过API调用使用notes属性时遇到了问题。直到一个月前,情况才开始好转,然后事情开始变得不稳定。是否有任何语法更改?下面是我的代码片段,它在for循环中返回一个错误。
错误消息"Undefined index: note_attribute right at the foreach line“
// 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'] ;
}
}
}非常感谢您的帮助。谢谢。
发布于 2012-09-16 22:36:18
这里的问题是由于XML节点语法的更改;Shopify有一个回归,它在响应中将note-attributes更改为note_attributes,然后又被改回。
https://stackoverflow.com/questions/12410179
复制相似问题