Forums

How to Add a percentage to a value? (5 posts)

  1. nalacat
    Member
    Posted 9 months ago #

    Hi All

    Id really appreciate it if anybody could tell me how i add 20% to:

    <?php echo $General->get_amount_format($Product->get_product_price_only($pid)); ?>

    This is an output value in my theme!

    Thank you in advance!

  2. popper
    Member
    Posted 9 months ago #

    Assuming that call returns a String:

    <?php
    $amount = $General->get_amount_format($Product>get_product_price_only($pid));
    $amount = (int)$amount;
    $amount = $amount + ($amount/100)*20;
    echo  $amount;
     ?>

    You can do it in one line, too, it's expanded a bit for readability's sake.

  3. nalacat
    Member
    Posted 9 months ago #

    Hi Popper!

    I tried it but it doesnt seem to work.

    The returned value if set on its own

    <?php echo $General->get_amount_format($Product->get_product_price_only($pid)); ?>

    Does return a price!

  4. popper
    Member
    Posted 9 months ago #

    Ok, and what is this price it returns? String, object? We're gonna need a bit of information here.

  5. RichardWPG
    Member
    Posted 9 months ago #

    Exactly..

Reply

You must log in to post.

About this Topic

Tags

No tags yet.