Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • BackTrack 5 R2
  • Wine 1.4 / 1.5.5
  • Mozilla Firefox 12...
  • Ubuntu 11.04
  • Angry Birds 1.1.2.1
  • Ubuntu 10.04.4 LTS
  • Linux Kernel 3.4
  • Ubuntu Manual 10.10
  • Adobe Flash Player...
  • Pidgin 2.10.4
  • Home > Linux > Programming > Libraries

    Webforce Cart 1.6

    Download button

    No screenshots available
    Downloads: 377  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Webforce Ltd | More programs
    LGPL / FREE
    April 6th, 2007, 15:24 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    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 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.

    What's New in This Release:

    · The empty cart function was fixed.



    Product's homepage

      


    TAGS:

    PHP class | shopping cart | online store | wfCart | Webforce | Cart



    HTML code for linking to this page:


    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM