X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Special Offers Module (https://forum.x-cart.com/showthread.php?t=1144)

funkydunk 01-09-2003 08:06 AM

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 !! :wink: 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

shan 01-09-2003 02:11 PM

Well done mate,

Your coming up with some great addons of late.

Hats off to you :-)

funkydunk 01-09-2003 10:49 PM

Necessity is the father of invention. :wink:

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

Thanks for the feedback.

There's more coming!

FishBookStore 01-10-2003 09:11 AM

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?

shan 01-10-2003 09:34 AM

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

funkydunk 01-10-2003 10:22 AM

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. :?

shan 02-07-2003 05:17 PM

Anyone created this as a side menu like the bestsellers has ?

funkydunk 02-07-2003 10:58 PM

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.

jgkiefer 04-14-2003 06:34 AM

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?

funkydunk 04-14-2003 10:55 AM

I look forward to seeing the code :wink:

Haven't got time to amend this myself at the moment - clients come first - , but feel free to amend away and post your results.


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

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.