php code for simple installments

Asked

Viewed 654 times

2

I have this code php to show the number of plots, but it shows like this: Parcel up to 6x without interest. I want him to show it like this: Parcele in up to 6x of 30 reais.

In the case of 30 real is only one example, it would have to divide the total number by 6 and show.

The code is this:

<?php
    $vezes = $_product->getData('parcelas');
    echo '<p><small><b>Parcele em até '.$vezes.' X sem juros</b></small><br />';
        for ( $i=1; $i <= $vezes; $i++ ) {
             echo '<small>'.$i.'x de '.$_coreHelper->currency($_product->getFinalPrice()/$i, true, false).'</small><br />';
        }
    echo '</p>';
?>

It also shows plots in lines, but this is no problem.

How would it look?

  • Take the final price variable divide by the times and use the number format to format the price

  • how would it look? I don’t know anything from php :\

  • Eita gave bad my answer.I will try for PC...

  • There I am on PC, I’ll assemble the answer again.

  • I posted an answer

1 answer

1


You can elaborate a variable to do the calculation and print it. Like this example:

<?php
$vezes = $_product->getData('parcelas');
$calc = $_coreHelper->currency($_product->getFinalPrice()/$vezes, true, false);
echo "<p><small><b>Parcele em até '".$vezes."' X sem juros de '".$calc."'</b></small><br />";
    for ( $i=1; $i <= $vezes; $i++ ) {
        echo '<small>'.$i.'x de '.$_coreHelper->currency($_product->getFinalPrice()/$i, true, false).'</small><br />';
    }
echo '</p>';
?>

I think you should solve your problem.

  • 1

    Perfect! Valeuzão André :D

Browser other questions tagged

You are not signed in. Login or sign up in order to post.