Introduction to Shopping Cart
Thank you for purchasing our script.
This guide should answer all your questions about how to use this script, you can browse the document
using the navigation sidebar on the left.
Description
Shopping Cart System is built in object oriented PHP 5 with a MySQL database that allows you to sell through your website. Is lightweight, flexible, customizable and simple application to use with small steps.
Some of the features include:
- Installation wizard
- Very compact
- Easy customization of templates
- Integrated AJAX
- Works in all major browsers
- Unlimited categories and subcategories
- Unlimited attributes (sizes, colors, etc.)
- Unlimited product images
- Discount coupon system
- Sell downloadable products: MP3's, software, etc
- Automatic image resizing
- WYSIWYG text editor
- PayPal (IPN)
- Payment upon delivery (COD)
- Bank transfer
- 100% Object Oriented
- Email templates
Installation
- Unzip the package in an empty directory and upload everything.
- Open a browser and go to the url where you put the Shopping Cart files.
- If you are running on a your own computer http://localhost/example/install/
- If on a live server http://www.example.com/install/
- Just follow the instructions and fill in the fields required to properly install the Shopping Cart.
Upgrade for 2.x to 2.7
These may include bug fixes or enhancements, and you may or may not wish to upgrade. It's always a good idea to backup everything up before you upgrade, especially if you have made any changes to the files, as the upgrade will overwrite all files.
- Backup your existing application files and database before making any changes.
- Delete the old files and folders, except config folder.
- Upload the new contents in your root directory, except config folder.
- Clear any cookies and your browser cache to avoid errors.
- Open a browser and go to the url where you put the Shopping Cart files.
- If you are running on a your own computer http://localhost/example/install/upgrade.php
- If on a live server http://www.example.com/install/upgrade.php
- Just follow the instructions to update your Shopping Cart.
NOTE:
- Always make a backup of your files and database first.
- It is strongly recommended not to upgrade your live store, make a copy of your store to another server and try to upgrade it first.
- If you have made any modifications in some files, your changes will be lost. Compare the new and old files and replace the necessary parts of code manually.
Usage examples
If you want you can use another CSS framework and if you know CSS you can create custom design. The Shopping Cart uses the simple template engine to separate layout and PHP logic. Template files will be written in pure HTML with some PHP calls for display the data, below are some examples.
Create a simple PHP file (example.php) which loads the template with available variables and outputs the result.
<?php //Include the common file require_once('common.php'); //Products $products = array(); foreach ($db->query("SELECT * FROM " . config_item('cart', 'table_products') . " ORDER BY product_id DESC LIMIT " . config_item('cart', 'per_page_catalog') . "") as $row) { $products[] = array( 'product_id' => $row['product_id'], 'product_thumbnail' => $row['product_thumbnail'], 'product_price' => $row['product_price'], 'product_name' => $row['product_name'] ); } //Template values $tpl->set('products', $products); //Display the template $tpl->display('template_name'); ?>
Create your template file (template_name.tpl) and save it in the templates folder with the tpl extension.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Title</title> </head> <body> <?php foreach ($products as $row): ?> <img src="<?php echo config_item('cart', 'site_url'); ?>uploads/images/<?php echo $row['product_thumbnail']; ?>" alt="" /> <?php echo price($row['product_price']); ?> <?php echo $row['product_name']; ?> <a href="product_details.php?product_id=<?php echo $row['product_id']; ?>">Read more</a> <?php endforeach; ?> </body> </html>
You can include external templates, useful for include header and footer if they are the same in all page of your website.
<?php require_once('header' . config_item('template', 'template_extension')); ?> <p></p> <?php require_once('footer' . config_item('template', 'template_extension')); ?>
Is very simple to use, for more details see the example files in the package downloaded.
Get categories menu
<?php echo get_categories(0); ?>
Authorizing users
Check if the user is logged in.
<?php if (!$authentication->logged_in() || !$authentication->is_group('customer')) header("Location: login.php"); ?>
Functions
- add_product()
- get_cart()
- empty_cart()
- remove_item()
- shipping_cost()
- tax_rate()
- subtotal()
- total()
- get_product()
- get_products()
- update_cart()
- checkout()
- check_coupon()
- get_coupon()
Add a new product
Function | Parameters | ||
---|---|---|---|
add_product() |
Product id - integer required Options array - array optional |
Usage
$cart->add_product(3, array()); $cart->add_product(3, NULL);
Get cart
Function | Parameters | Return | |
---|---|---|---|
get_cart() | array |
Usage
$cart->get_cart();
Empty the shopping cart
Function | Parameters | ||
---|---|---|---|
empty_cart() |
Usage
$cart->empty_cart();
Remove item from cart
Function | Parameters | ||
---|---|---|---|
remove_item() |
Cart id - integer required Product id - integer required |
Usage
$cart->remove_item(1, 1);
Returns the shipping cost
Function | Parameters | Return | |
---|---|---|---|
shipping_cost() | string |
Usage
$cart->shipping_cost();
Returns the tax rate cost
Function | Parameters | Return | |
---|---|---|---|
tax_rate() | string |
Usage
$cart->tax_rate();
Returns the subtotal cost
Function | Parameters | Return | |
---|---|---|---|
subtotal() | string |
Usage
$cart->subtotal();
Returns the total cost
Function | Parameters | Return | |
---|---|---|---|
total() | string |
Usage
$cart->total();
Get product details
Function | Parameters | Return | |
---|---|---|---|
get_product() | Product id - integer required | array |
Usage
$cart->get_product(1);
Get the products
Function | Parameters | Return | |
---|---|---|---|
get_products() | Category id - integer required | array |
Usage
$cart->get_products(1);
Update the cart
Function | Parameters | ||
---|---|---|---|
update_cart() |
Cart id - integer required Product id - integer required Quantity - integer required |
Usage
$cart->update_cart(2, 1, 3);
Checkout
Function | Parameters | ||
---|---|---|---|
checkout() |
User id - integer required User email address - string required Payment method - string required Comment - string optional |
Usage
$cart->checkout(1, 'email@example.com', 'PayPal', 'Comment');
Check coupon
Function | Parameters | ||
---|---|---|---|
check_coupon() | Coupon code - string required |
Usage
$cart->check_coupon('123456789');
Get coupon details
Function | Parameters | ||
---|---|---|---|
get_coupon() | Coupon id - integer required |
Usage
$cart->get_coupon(1);
Authentication configuration
Database tables
Description | Value |
---|---|
The users table | $config['table_users'] |
The groups table | $config['table_groups'] |
The user profiles table | $config['table_profiles'] |
Website details
Description | Value |
---|---|
The title of your website | $config['site_title'] |
The site url of your website | $config['site_url'] |
The absolute path of your server | $config['absolute_path'] |
Administrator email address | $config['admin_email'] |
Registration settings
Description | Value |
---|---|
Default ID of user group | $config['default_group'] |
Default ID of admin group | $config['admin_group'] |
Enables or disables email activation | $config['email_activation'] |
Set true to be approved by the admin | $config['approve_registration'] |
Time for user activation | $config['email_activation_expire'] |
How long to remember the user (seconds) | $config['user_expire'] |
Welcome message | $config['email_subject_1'] |
Send new password | $config['email_subject_2'] |
New user registered | $config['email_subject_3'] |
General settings
Description | Value |
---|---|
Secret word of the token | $config['secret_word'] |
Cart configuration
Database tables
Description | Value |
---|---|
The categories table | $config['table_categories'] |
The category products table | $config['table_category_products'] |
The products table | $config['table_products'] |
The product images table | $config['table_product_images'] |
The digital goods table | $config['table_digital_goods'] |
The carts table | $config['table_carts'] |
The cart product options table | $config['table_cart_product_options'] |
The countries table | $config['table_countries'] |
The customers table | $config['table_customers'] |
The addresses table | $config['table_addresses'] |
The orders table | $config['table_orders'] |
The order status table | $config['table_order_status'] |
The order status descriptions table | $config['table_order_status_descriptions'] |
The order products table | $config['table_order_products'] |
The order digital goods table | $config['table_order_digital_goods'] |
The order options table | $config['table_order_options'] |
The coupons table | $config['table_coupons'] |
The product options table | $config['table_product_options'] |
The product option values table | $config['table_product_option_values'] |
Website details
Description | Value |
---|---|
The title of your website | $config['site_title'] |
The site url of your website | $config['site_url'] |
The absolute path of your server | $config['absolute_path'] |
Administrator email address | $config['admin_email'] |
Cart settings
Description | Value |
---|---|
New order | $config['email_subject'] |
Number of items display per page (Catalog) | $config['per_page_catalog'] |
Number of items display per page (Admin) | $config['per_page_admin'] |
The currency symbol | $config['currency_symbol'] |
The currency code | $config['currency_code'] |
The position of the currency symbol (left or right) | $config['currency_position'] |
The cost of the shipping | $config['shipping_cost'] |
The tax description | $config['tax_description'] |
The tax rate | $config['tax_rate'] |
The tax rate to shipping costs true = Enabled false = Disabled |
$config['tax_shipping'] |
How long to remember the user cart (seconds) | $config['cart_expire'] |
Email address of paypal account | $config['paypal_email'] |
PayPal URL for payment completed | $config['paypal_return'] |
PayPal URL for payment cancelled | $config['paypal_cancel_return'] |
PayPal URL for IPN notification | $config['paypal_notify_url'] |
Paypal sandbox 0 = For production mode 1 = For testing |
$config['paypal_sandbox'] |
Message logging directory | $config['log_path'] |
New order notification 0 = Disabled 1 = Enabled |
$config['new_order_notification'] |
Database configuration
Description | Value |
---|---|
The hostname of your database server | $config['hostname'] |
The username used to connect to the database | $config['username'] |
The password used to connect to the database | $config['password'] |
The name of the database you want to connect to | $config['dbname'] |
The database type. Currently supported: mysql | $config['driver'] |
The character set used in communicating with the database | $config['char_set'] |
Template configuration
Description | Value |
---|---|
The site url of website | $config['site_url'] |
The absolute path of your server | $config['absolute_path'] |
The extension of your templates | $config['template_extension'] |
Upload configuration
Description | Value |
---|---|
The path for the upload | $config['upload_path'] |
Files allowed for upload | $config['allowed_filetypes'] |
The maximum size (bytes) | $config['max_filesize'] |
The maximum width of thumbnail (in pixels) | $config['max_width_thumbnail'] |
The maximum height of thumbnail (in pixels) | $config['max_height_thumbnail'] |
The maximum width (in pixels) | $config['max_width'] |
The maximum height (in pixels) | $config['max_height'] |
Email templates
Email templates are used for the emails sent (using HTML) from your website. You can customize the templates using your text. All templates are inside the folder templates/mail/, below the welcome template as an example:
<html> <head> <title>%%SITE_TITLE%%</title> </head> <body> <p>Hello %%FIRST_NAME%% %%LAST_NAME%%!</p> <p>Welcome and thank you for registering at %%SITE_TITLE%%!</p> <p>Here are your account details:</p> <p> Name: %%FIRST_NAME%% %%LAST_NAME%%<br /> Email address: %%EMAIL%%<br /> Password: *hidden* </p> <p> Thanks,<br /> %%SITE_TITLE%% </p> <p>* Do not respond to this email *</p> <p> This is an automatic email sent from our support system.<br /> Do not respond to this email, you will not receive any response! </p> <p><a href="%%SITE_URL%%" target="_blank">%%SITE_TITLE%%</a></p> </body> </html>
You may notice text that looks like this %%EMAIL%%. This is called a token and is used by the system to fill in information to be put in the email. In this case %%EMAIL%% is the token to display the user email.
Requirements (recommended)
- Operating System
- Linux
- Web server
- Apache
- MySQL 5+
- PHP 5.2+ (PDO extension and GD library required)
- PHP Settings
- File uploads: On
- Session: On
- Register Globals: Off
Files included
- Cart library
- Database tables
- jQuery library
- jQuery UI
- jQuery plugin: Validation
- jQuery plugin: BlockUI
- jQuery plugin: Fancybox
- jQuery plugin: Cookie
- jQuery plugin: qTip2
- jQuery plugin: jqPlot
- TinyMCE WYSIWYG editor
- Custom JS files
- Minified
- Uncompressed for developers
- Default and Core CSS file: style.css
- Example: example folder
Changelog
v2.7 (08/01/2013)
* New: Notifications for new orders
* Updated: Currencies list
* Updated: Libraries
* Updated: Database tables
* Removed: Useless column display_name from database
* Few more fixes and enhancements
v2.6 (19/05/2012)
* Fix: Incorrect currency symbols
v2.5 (23/04/2012)
* New: Template support
* New: Ability to viewing statistics for Top 5 sellers in the admin area
* New: Ability to set position of currency symbol next to a price
* New: Product options
* New: Ability to upload unlimited images for product
* New: Ability to save the settings in the admin area
* New: Ability to search the products
* New: Payment methods (Bank transfer - Cash on delivery)
* Updated: Libraries
* Updated: Database tables
* Few more fixes and enhancements
v2.4 (05/10/2011)
* Fix: Check quantity in the stock
v2.3 (28/07/2011)
* Fix: Currency symbol in the order email
v2.2 (02/07/2011)
* Few more fixes and enhancements
v2.1 (17/06/2011)
* Fix: Shipping cost PayPal
v2.0 (15/05/2011)
* New: WYSIWYG text editor
* New: Option to sell digital goods
* New: Category management
* New: PayPal IPN technology
* New: Authentication system
* New: Order management
* New: Customer registration
* New: Customer management
* Few more fixes and enhancements
v1.0 (28/03/2011)
* Initial release
Credits
- jQuery
- jQuery plugin: Validation
- jQuery plugin: BlockUI
- jQuery plugin: Fancybox
- jQuery plugin: qTip2
- jQuery plugin: jqPlot
- jQuery plugin: Cookie
- 960 Grid System
- SyntaxHighlighter
- TinyMCE WYSIWYG editor
- Led Icons
- Retina Display Icons
Support notes
Right now we receive many emails and requests for support than we can manage quickly. Many times we can
answer the same day but others take much longer.
Before you send a request for support make sure you have done the following things:
- Read the full documentation file.
- Check if your question is not already in the Item Discussion section.
To be able to help solve a problem quickly, please read our profile page. We will do our best to help.