Shopping Cart Tutorial PHP Shopping Cart Tutorial
Learn how to create an online store with PHP and MySQL
Free shopping cart    Download:
Shop-Script FREE
Shop-Script FREE User Guide (PDF; 0 Kb)
View Live Demo    View online store demo
 Introduction
 Basic concepts
 Technologies
 File structure
 Database structure
 Back end
   Password protection
   Products catalog: structure
   Product catalog: viewing
   Managing categories
   Managing products
   Special offers
   Managing orders
 Front end
   Viewing products catalog
   Product search
   Shopping cart
   Checkout
   PayPal integration
 Security
 Live Demo
 Author
 Terms Of Use

Shopping cart software

 

Managing special offers

Publishing special offers is a good way to decorate your online storefront:

Special offers with bright pictures will surely catch your visitors' attention.

Publishing and managing special offers is easier than you can imagine. To do this we only have to maintain a list of products which will appear in the special offers list. This list can be stored in a single table with following structure:

offerID is a primary key which identifies special offer entry.
productID refers to a certain product from PRODUCT table.
sort_order indicates position of this entry in the special offers list shown to customers in storefront.

To add a product to the special offers list we click  link in the "Categories and products " department of administrative area.
It brings the page

admin.php?dpt=catalog&sub=special&new_offer=[productID]

(where [productID] is ID of the product which we are adding to the special offers list) and executes following PHP code (includes/admin/sub/catalog_special.php)

<?php

    
if (isset($_GET["new_offer"])) //add new special offer
    
{
        
db_query("insert into ".SPECIAL_OFFERS_TABLE." (productID, sort_order) values ('".$_GET["new_offer"]."',0)") or die (db_error());
        
header("Location: admin.php?dpt=catalog&sub=special");
    }

?>

That is all. The product has been added to the special offers list and will now appear in the storefront homepage highlighted products.

Presenting special offer products in both back end and storefront homepage can be done by fetching a list of these products using following SQL query:

SELECT productID FROM `SPECIAL_OFFER` ORDER BY sort_order;

and then fetching each product information from this list:

SELECT name, Price FROM `PRODUCT` WHERE productID=$each_productID_from_the_previous_query;

 

 


Copyright © 2006 WebAsyst LLC