Personal License $9.99

1 site, unlimited servers No source distribution Commercial use allowed Can modify source Read full license

You need to log-in or create an account
  • Create an account
  • Log-in
  • Please use your real name.
  • Account activation link will be sent to this address.
  • Minimum 8 characters

Clicking this button confirms you read and agreed to the terms of use and privacy policy.

Price: $ 9.99

View Pricing 14 days money-back guarantee

DevKen Cart Calculator Class

General purpose shopping cart calculator that accepts shipping, handling, tax and discounts on item and cart levels.

Description

Like a real world shopping experience when I finish collecting all the items I want to purchase into my shopping cart I proceed to the register where they will tally the total cost of my items. The DevKen Cart Calculator Class is that piece of the puzzle, it takes a shopping cart and calculates the total costs.

The Cart Calculator Class returns an augmented shopping cart that includes handling charges, taxes, discounts, subtotals and totals for each item. It also returns the calculations for the entire cart. Returning items like tax, shipping and handling, total, subtotal and more. Check out the demo page for a complete list.

Back to top

Example Usage

// create a register object
$Cart_Calculator= new Cart_Calculator(array(
    'shipping' => 10.53,
    'tax' => 6.5,
    'discount' => '5%', 
    'handling' => 12.50,
    'prefix' => '$'
));

$cart[0]['title'] = 'Product 1';    
$cart[0]['price'] = 12.99;
$cart[0]['qty'] = 3;
$cart[1]['title'] = 'Product 2';
$cart[1]['price'] = 25.50;
$cart[1]['qty'] = 9;
$cart[1]['discount'] =5.50;
$cart[1]['tax'] = 3.5;
$cart[1]['handling'] = 2.50;

// send the cart to the register for calculating
list($cart,$totals) = $Cart_Calculator->getTotals($cart);

// print the updated cart for viewing
print_r($cart); 

// print the totals array for viewing
print_r($totals); // cart totals

Questions & Comments

No questions have been posted yet

Leave a comment

You must be logged-in to leave a comment.
Log-in now or register for a free account.
You must be logged-in to vote. Log-in to your account or register now.

User Reviews

No reviews have been submitted yet.

Price: $ 9.99

View Pricing 14 days money-back guarantee