Webforce Cart


Webforce Cart (wfCart) is a free PHP shopping cart class you can use a component of a PHP based online store. Its 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 Cart To 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[cart]; 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 cart echo $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[id]." "; echo "Quantity:".$item[qty]." "; echo "Price :".$item[price]." "; echo "Info :".$item[info]." "; echo "Subtotal".$item[subtotal]." "; } Note, subtotal is quantity X price for that item, not a running total.. Extending Webforce Cart There 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[info][color] etc. Whats New in This Release: · The empty cart function was fixed.. Webforce Cart ( aka wfCart ) is a free Shopping Cart class for PHP.

Webforce Cart - Php Shopping Cart Class - Php Shopping Cart - You Do Not - Php Shopping - Shopping Cart - Use A - Cart - Item - Webforce - Price - Quantity - Echo

Published By:Webforce Ltd

License Type:Freeware

Date Added:26 October, 2010




Size:3.1 KB

Platform: Linux

What people say
- required fields
Related Downloads

More than 2,000 online store owners depend on our shopping cart and hosting to manage their e-commerce operation from top to bottom. FreeTpl Shop is an Free Version online shop e-commerce solution that is available for free download.

DateAug 13, 2010






CategoryLinux Utilities

FreeTpl PHP Shopping Cart supports Downloadable products with instant activation option, especially useful for software companies selling their products via the Internet & could be easily integrated into any system widely utilizing the power of templ

DateAug 31, 2010

AuthorFreeTpl Shop

Size5.3 MB




CategoryLinux Utilities

DolceCart v 1.0 Php Script offers a secure shopping cart to current websites with HTML or PHP code. A shopping cart with a secure server for about the price of a secure server alone. DolceCart is an ecommerce service that gives web site owners a m

DateAug 2, 2014


Size92.3 KB



PlatformLinux, Linux GPL, Linux Gnome, Linux Open Source

CategoryLinux Business


Clarion is a Perl extension for reading CLARION data files. ABSTRACT This is a perl module to access CLARION 2.1 files. At the moment only read access to the files are provided by this package.

DateOct 12, 2010

AuthorIlya Chelpanov

Size6.1 KB




CategoryLinux Programming

SlaBuntuVMware is a useful installation suite for installing VMware Server on Slackware or Ubuntu. The project automatically downloads packages from the VMware site. Tested on Slackware 11. (Slackware 10.

DateOct 2, 2010

AuthorLorenzo Allori

Size12.3 KB




CategoryLinux Internet