Webforce Cart

Webforce Cart (wfCart) is a free PHP shopping cart class you can use a component of a PHP based online store.
Download

Webforce Cart Ranking & Summary

Advertisement

  • Rating:
  • License:
  • LGPL
  • Price:
  • FREE
  • Publisher Name:
  • Webforce Ltd
  • Publisher web site:
  • http://www.webforcecart.com/

Webforce Cart Tags


Webforce Cart Description

Webforce Cart (wfCart) is a free PHP shopping cart class you can use a component of a PHP based online store. Webforce Cart (wfCart) is a free PHP shopping cart class you can use a component of a PHP based online store. It's designed as a component for PHP developers who would rather write their own store rather than a complete solution.Instructions and examples for the free PHP Shopping CartTo use the cart in an existing script:Rename wfcart.php.txt to wfcart.php and upload to your server. Then include the file:include("wfcart.php");Start the session, and assign the cart to it. NOTE: You must include the file wfcart.php before you start the session, its just the way PHP works.session_start();$cart =& $_SESSION;if(!is_object($cart)) $cart = new wfCart();Then you can use the functions like $cart->get_contents();, these functions are documented below.Adding an Item - $cart->add_item( code , quantity , price , info )If you have a widget with code AB313 and a price of $40.11, you can add it to the cart with :$cart->add_item('AB313',1,40.11,'Widget AB313 Standard');If the item AB313 is alreay in the cart, then the quantity of it will be increased by the quantity supplied to the function, in this case 1. The itemid must be unique, and can be letters and/or numbers. Deleting an Item - $cart->del_item( itemid );E.g. to delete the item ID 123 $cart->del_item('123');Changing the quantity of an item - $cart->edit_item( itemid, new_quantity );For example :$cart->edit_item('HA2',3);If you set the quanitity to zero, the item is deleted.Getting the number of items in a cartecho $cart->itemcount;Getting the total value of the cart.echo $cart->total;Emptying the cart$cart->empty_cart();Getting the cart contents$items = $cart->get_contents();$items is an array, so the following code displays the items.foreach($items as $item) { echo "Code/ID :".$item.""; echo "Quantity:".$item.""; echo "Price :".$item.""; echo "Info :".$item.""; echo "Subtotal".$item."";}Note, subtotal is quantity X price for that item, not a running total..Extending Webforce CartThere are 2 functions you can create that will enable more flexability.One is wf_get_price( itemid, qty ). If you need to do pricing based on Quantity ( e.g. bulk discounts ) then you can create a function called wf_get_price to do what you need itto do. If you do not pass a price to add_item, then the wf_ get_price function will be called. If you use this functionality, AND your price is quantity dependant, then you must uncomment the line in the edit_item function.The other is wf_get_info, again, if you do not pass info to add_item then get_info will be called. TIP: you do not have to pass a string to add_item(), you could use an array of infomation instead. e.g. add_item( 'AS2112',5,19.95,array('size'=>'large','color'=>'red')); then when you use get_contents, you echo $item etc.What's New in This Release:· The empty cart function was fixed.


Webforce Cart Related Software