首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Notes attributes语法已更改?-通过API调用Notes attributes for me失败

Notes attributes语法已更改?-通过API调用Notes attributes for me失败
EN

Stack Overflow用户
提问于 2012-09-13 23:51:28
回答 1查看 260关注 0票数 2

您好,购物开发人员!

我在通过API调用使用notes属性时遇到了问题。直到一个月前,情况才开始好转,然后事情开始变得不稳定。是否有任何语法更改?下面是我的代码片段,它在for循环中返回一个错误。

错误消息"Undefined index: note_attribute right at the foreach line“

代码语言:javascript
复制
// 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'] ;
        }
    }
}

非常感谢您的帮助。谢谢。

EN

回答 1

Stack Overflow用户

发布于 2012-09-16 22:36:18

这里的问题是由于XML节点语法的更改;Shopify有一个回归,它在响应中将note-attributes更改为note_attributes,然后又被改回。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12410179

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档