Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Special Offers Module

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #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
  #2  
Old 01-09-2003, 02:11 PM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

Well done mate,

Your coming up with some great addons of late.

Hats off to you
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #3  
Old 01-09-2003, 10:49 PM
 
funkydunk funkydunk is offline
 

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

Default

Necessity is the father of invention.

Just had a client who needed these bits so I put them together.

Thanks for the feedback.

There's more coming!
__________________
ex x-cart guru
Reply With Quote
  #4  
Old 01-10-2003, 09:11 AM
 
FishBookStore FishBookStore is offline
 

Advanced Member
  
Join Date: Oct 2002
Posts: 58
 

Default Hmmm...

I was thinking of doing something like this but I wanted it to be something like Bargain of the Day or Week.

I wanted to give everything a Bargain Price. The script would randomly pick an item for the time period. It would just need to check against a timestamp to see if it needed to generate a new bargain or run a cron job.

I would also want it to show the Bargain Price on the product page.


The one problem I see with yours is couldn't a customer simply continue to reload the page until it loaded the item they wanted to get the discount?
__________________
Regards
Mark

FishBookStore.com
Version (3.3.1) (Not Live)
Reply With Quote
  #5  
Old 01-10-2003, 09:34 AM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

It doesnt matter i suppose as all the items that will show up are chosen from the list of products that you have set as discounted.

This just puts a few on the front page to show them off
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #6  
Old 01-10-2003, 10:22 AM
 
funkydunk funkydunk is offline
 

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

Default

Shan,

Bang on.

If you haven't selected a discount it wont pick it..simple as that.

Now getting the system to do a discount automatically, now that is another thing, not sure how that would work.
__________________
ex x-cart guru
Reply With Quote
  #7  
Old 02-07-2003, 05:17 PM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

Anyone created this as a side menu like the bestsellers has ?
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #8  
Old 02-07-2003, 10:58 PM
 
funkydunk funkydunk is offline
 

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

Default

Shan,

Yep - Am building a site at the moment with this in a lhs menu.

Limited it to show 3 products though cos of space.
__________________
ex x-cart guru
Reply With Quote
  #9  
Old 04-14-2003, 06:34 AM
 
jgkiefer jgkiefer is offline
 

Advanced Member
  
Join Date: Apr 2003
Posts: 85
 

Default

Quote:
Originally Posted by funkydunk
Limited it to show 3 products though cos of space.

How about one random discounted product or the option for more?
Reply With Quote
  #10  
Old 04-14-2003, 10:55 AM
 
funkydunk funkydunk is offline
 

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

Default

I look forward to seeing the code

Haven't got time to amend this myself at the moment - clients come first - , but feel free to amend away and post your results.
__________________
ex x-cart guru
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 05:50 AM.

   

 
X-Cart forums © 2001-2020