Jump to content

How to Access Protected Property of an Object?

Recommended Posts

Hi there,

I have returned $vars from EmailPreSend Hooks like this

Array (
    [messagename] => Other Product/Service Welcome Email
    [relid] => 805
    [mergefields] => Array (
        [service_first_payment_amount] => WHMCS\View\Formatter\Price Object (
            [price:protected] => 350000
            [currency:protected] => Array (
                [id] => 1
                [code] => IDR
                [prefix] => Rp
                [suffix] => IDR
                [format] => 3
                [rate] => 1.00000
            [defaultFormat:protected] => {PREFIX}{PRICE}{SUFFIX}
            [defaultCurrencyDescriptor:protected] => Array (
                [format] => 1
                [prefix] =>
                [suffix] =>

How to print "350000" on price protected object from ['mergefields']['service_first_payment_amount']
I try $vars['mergefields']['service_first_payment_amount']->price;
But i get message Error: Cannot access protected property WHMCS\View\Formatter\Price::$price

Link to comment
Share on other sites

I think it should just be the variable below if you just want to get the currency formatted price...


if you just want the raw value, try....

Link to comment
Share on other sites

Join the conversation

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

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated