Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Ovunc Tukenmez  >  Taksit  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example
Class: Taksit
Calculate prices for different payment processors
Author: By
Last change:
Date: 1 year ago
Size: 1,856 bytes
 

Contents

Class file image Download
<?php
require_once("Taksit.php");

$taksit = new Taksit(265); //instantiate class with original price of 265 USD
$taksit->addRate(array(
                
'name' => 'credit card',
                
'installment' => 1));
$taksit->addRate(array(
                
'name' => 'credit card',
                
'installment' => 12,
                
'percent' => 3.8));
$taksit->addRate(array(
                
'name' => 'paypal'//define paypal commission rate which is 2.9% + 0.30 USD
                
'percent' => 2.9,
                
'fixed' => 0.30));
$taksit->addRate(array(
                
'name' => 'wire transfer',
                
'percent' => 5//lets make 5% discount on wire transfers
                
'make_discount' => 1
                
));

$prices $taksit->getPriceArray();

//echo $taksit->getPrice('credit card', 12); //you can also get the price directly by calling getPrice() function.

//create table
?>
<table border="1">
<?php
foreach ($prices as $payment_type => $options){
?>
<tr>
    <td colspan="3" bgcolor="#FFFF00" align="center"><?php echo $payment_type?></td>
</tr>
<tr>
    <th width="100">Installment</th>
    <th width="100">Price</th>
    <th width="100">Discount</th>
</tr>
<?php
    
foreach ($options as $option){
?>
<tr>
    <td align="center"><?php echo $option['installment']; ?></td>
    <td align="right"><?php echo number_format($option['price'], 2'.'','); ?> USD</td>
    <td align="center"><?php if ($option['discount_percent'] > && $option['discount_fixed'] > 0){ echo "%{$option['discount_percent']} + {$option['discount_fixed']} USD"; } else if ($option['discount_percent'] > 0) { echo "%{$option['discount_percent']}"; } else if ($option['discount_fixed'] > 0) { echo "{$option['discount_fixed']} USD"; } else { echo "-"; } ?></td>
</tr>
<?php
    
}
}
?>
</table>