• Integer vitae nulla!

    Integer vitae nulla!

    Suspendisse neque tellus, malesuada in, facilisis et, adipiscing sit amet, risus. Sed egestas. Quisque mauris. Duis id ligula. Nunc quis tortor. In hendrerit, quam vitae mattis interdum, turpis augue viverra justo, sed semper sem lorem sed ligula. Curabitur id urna nec risus volutpat ultrices....

  • Suspendisse neque tellus

    Suspendisse neque tellus

    Suspendisse neque tellus, malesuada in, facilisis et, adipiscing sit amet, risus. Sed egestas. Quisque mauris. Duis id ligula. Nunc quis tortor. In hendrerit, quam vitae mattis interdum, turpis augue viverra justo, sed semper sem lorem sed ligula. Curabitur id urna nec risus volutpat ultrices....

  • Curabitur faucibus

    Curabitur faucibus

    Suspendisse neque tellus, malesuada in, facilisis et, adipiscing sit amet, risus. Sed egestas. Quisque mauris. Duis id ligula. Nunc quis tortor. In hendrerit, quam vitae mattis interdum, turpis augue viverra justo, sed semper sem lorem sed ligula. Curabitur id urna nec risus volutpat ultrices....

Sunday, 27 February 2011

Script Managing Spesial Offer

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;

0 comments:

Post a Comment