首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从Recurly_CouponRedemptionList获取优惠券详细信息

问如何从Recurly_CouponRedemptionList获取优惠券详细信息
EN

Stack Overflow用户
提问于 2017-01-12 00:38:16
回答 1查看 85关注 0票数 1

我使用的是Recurly API 2.7,这是最新版本。我在从发票对象获取优惠券详细信息时遇到问题。

我想在这个结果中获取第一个赎回对象的优惠券对象。

代码语言:javascript
复制
$i = $ss->invoice->get();

if ($i->redemptions) {
    $r = $i->redemptions->get();
    print_r($r);
    if ($r->count > 0) {
        $coupon = $r[0]->coupon->get();
    }
}

但是$r没有返回我期望的Recurly_CouponRedemption对象。

代码语言:javascript
复制
Recurly_CouponRedemptionList Object
(
    [_position:Recurly_Pager:private] => 0
    [_count:protected] => 1
    [_objects:protected] => Array
        (
            [0] => Recurly_CouponRedemption Object
                (
                    [_values:protected] => Array
                        (
                            [coupon] => Recurly_Stub Object
                                (
                                    [objectType] => coupon
                                    [_href:protected] => https://xxx.recurly.com/v2/accounts/test
                                    [_client:protected] => Recurly_Client Object
                                        (
                                            [_apiKey:Recurly_Client:private] => 
                                            [_acceptLanguage:Recurly_Client:private] => en-US
                                        )

                                    [_links:protected] => Array
                                        (
                                        )

                                )

                            [account] => Recurly_Stub Object
                                (
                                    [objectType] => account
                                    [_href:protected] => https://xxx.recurly.com/v2/accounts/test
                                    [_client:protected] => Recurly_Client Object
                                        (
                                            [_apiKey:Recurly_Client:private] => 
                                            [_acceptLanguage:Recurly_Client:private] => en-US
                                        )

                                    [_links:protected] => Array
                                        (
                                        )

                                )

                            [uuid] => 0b00000000000000000000000
                            [single_use] => 
                            [total_discounted_in_cents] => 500
                            [currency] => USD
                            [state] => active
                            [coupon_code] => 5off
                            [created_at] => DateTime Object
                                (
                                    [date] => 2017-01-11 16:30:09
                                    [timezone_type] => 2
                                    [timezone] => Z
                                )

                            [updated_at] => DateTime Object
                                (
                                    [date] => 2017-01-11 16:30:09
                                    [timezone_type] => 2
                                    [timezone] => Z
                                )

                        )

                    [_unsavedKeys:protected] => Array
                        (
                        )

                    [_errors:protected] => Recurly_ErrorList Object
                        (
                            [transaction] => 
                            [transaction_error] => 
                            [errors:Recurly_ErrorList:private] => Array
                                (
                                )

                        )

                    [_href:protected] => 
                    [_client:protected] => Recurly_Client Object
                        (
                            [_apiKey:Recurly_Client:private] => 
                            [_acceptLanguage:Recurly_Client:private] => en-US
                        )

                    [_links:protected] => Array
                        (
                        )

                )

        )

    [_href:protected] => test
    [_client:protected] => Recurly_Client Object
        (
            [_apiKey:Recurly_Client:private] => 
            [_acceptLanguage:Recurly_Client:private] => en-US
        )

    [_links:protected] => Array
        (
        )

)

谢谢你的帮助。

EN

回答 1

Stack Overflow用户

发布于 2017-01-13 01:14:10

优惠券详细信息是兑换对象中的存根对象。

附件中的代码片段演示了如何调用优惠券存根并返回一些样例优惠券详细信息。

该调用还包括返回格式化数组中的优惠券对象,以便更好地查看可用于返回的优惠券参数/值。

https://gist.github.com/ianatrecurly/fc47fb5c98deb999cde182402049050b

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

https://stackoverflow.com/questions/41596097

复制
相关文章

相似问题

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