Jump to content

Get Object Variable


jarvis
Go to solution Solved by requinix,

Recommended Posts

Hi,

 

Apologies If I've got the title wrong but I'm trying to obtain a value from an array, however, it's an object (?)

Array
(
    [test] => WC_Coupon Object
        (
            [code] => test
            [id] => 1529
            [exists] => 1
            [discount_type] => percent_product
            [coupon_amount] => 10
            [individual_use] => yes
            [product_ids] => Array

I need to get coupon_amount

 

I thought I could use $my_coupon[0]->coupon_amount; but believe I've confused myself or misunderstood!

 

Any advice is gratefully received!

Thanks

Link to comment
Share on other sites

  • Solution

That output is for $my_coupon, right?

 

$my_coupon

Array
(
is an array

[test]
with a "test" key

=> WC_Coupon Object
with a WC_Coupon object as the value

[coupon_amount]
which has a "coupon_amount" property

=> 10
with the value 10.

 

So

$my_coupon["test"]->coupon_amount
Doing it this way means you need to know the coupon code. Do you?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.