View Single Post
  #1  
Old 01-09-2003, 08:06 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default Special Offers Module

I have now completed a special offers part to show them on the home page. the code is as follows:

First create a specials.php file in xcart/customer this selects 6 items at random that are marked as discounted from the main/market price.

Code:
<? // the database query $query = "SELECT * FROM $sql_tbl[products],$sql_tbl[pricing] WHERE forsale='Y' AND avail>0 AND $sql_tbl[products].productid=$sql_tbl[pricing].productid AND discount > 0 ORDER BY RAND() LIMIT 6 "; // give the product array to smarty to make it available sitewide. $specials = func_query($query); $smarty->assign("specials",$specials); ?>

Then add the following line into customer/home.php after the require featured proudcts bit.
Code:
require "./specials.php";

Then amend welcome.tpl to add the following code to where you want it to appear:
Code:
{include file="customer/main/specials.tpl" specials=$specials}

Then amend skin1/customer/home_main.tpl to:
Code:
{if $smarty.get.mode eq "subscribed"} {include file="main/subscribe_confirmation.tpl"} {elseif $smarty.get.mode eq "unsubscribed"} {include file="main/unsubscribe_confirmation.tpl"} {elseif $main eq "search"} {include file="customer/main/search_result.tpl"} {elseif $main eq "advanced_search"} {include file="customer/main/advanced_search.tpl"} {elseif $main eq "cart"} {include file="customer/main/cart.tpl"} {elseif $main eq "wishlist"} {if $active_modules.Wishlist ne ""} {include file="modules/Wishlist/wishlist.tpl"} {/if} {elseif $main eq "anonymous_checkout"} {include file="customer/main/anonymous_checkout.tpl"} {elseif $main eq "order_message"} {include file="customer/main/order_message.tpl"} {elseif $main eq "checkout"} {include file="customer/main/checkout.tpl"} {elseif $main eq "product"} {include file="customer/main/product.tpl" product=$product} {elseif $main eq "giftcert"} {include file="modules/Gift_Certificates/giftcert.tpl"} {elseif $main eq "subscriptions"} {include file="modules/Subscriptions/subscriptions.tpl"} {elseif $main eq "catalog" and $current_category.category eq ""} {include file="customer/main/welcome.tpl" f_products=$f_products specials=$specials} {elseif $main eq "catalog"} {include file="customer/main/subcategories.tpl" cat=$cat} {else} {include file="common_templates.tpl"} {/if}

Then and we are nearly there now !! create a special.tpl in skin1/customer/main as follows:
Code:
{capture name=dialog} {if $specials ne ""} {include file="customer/main/products.tpl" products=$specials} {else} {$lng.txt_no_specials} {/if} {/capture} {include file="dialog.tpl" title=$lng.lbl_special_offers content=$smarty.capture.dialog extra="width=100%"}

You will see that I have added two extra fields into the languages, one to display if there are no special offers and one for the title to the main box.

Enjoy.

Funkydunk
__________________
ex x-cart guru
Reply With Quote