WORKS ON 3.4.4
Here is what I have and it seems to be working fine.
It will only show your coupons to customers WHEN....
[1] They are marked as VIEWABLE when created
[2] If they are ACTIVE
[3] They have NOT expired
I hope I have this documented well enough. If anyone see's any issues please let me know.
1
#######################
SQL DATABASE CHANGES
Need to add new field at the end of the discount coupons table
#######################
status_view` char(1) NOT NULL default 'N'
2
#######################
Add New text and label varibles in Language Library
#######################
lbl_promotions
txt_use_coupon
3
#######################
Create New Files
#######################
Save below code as: skin1/customer/coupons.tpl
Code:
{* $Id: coupons.tpl,v 1.10 2003/04/22 10:10:59 svowl Exp $ *}
{include file="location.tpl" last_location="Store coupons"}
{include file="main/popup_product_js.tpl"}
{capture name=dialog}
{if $coupons ne ""}
<table width="100%" border=0>
<tr><td class=TableHead>Coupon Code</td><td class=TableHead>Discount</td><td class=TableHead colspan=2>Expires</td></tr>
{section name=prod_num loop=$coupons}
<tr>
<td>
<font color="red">{$coupons[prod_num].coupon}</font>
</td>
<td>{if $coupons[prod_num].coupon_type eq "absolute"}{include file="currency.tpl" value=$coupons[prod_num].discount}{elseif $coupons[prod_num].coupon_type eq "percent"}{$coupons[prod_num].discount}%{else}Free ship.{/if}</td>
<td nowrap>
{$coupons[prod_num].expire|date_format:"%b/%d/%Y"}
</td>
<td></td>
</tr>
<tr>
<td colspan=4>
This coupon applies the discount on orders
{if $coupons[prod_num].productid ne 0}
which contain product #{$coupons[prod_num].productid}
{elseif $coupons[prod_num].categoryid ne 0}
which contain product(s) from category #{$coupons[prod_num].categoryid}
{else}
greater than {include file="currency.tpl" value=$coupons[prod_num].minimum}
{/if}
<hr size=1 noshade>
</td>
</tr>
{/section}
<tr>
<td></td>
</tr>
</table>
{$lng.txt_use_coupon}
{/if}
{/capture}
{include file="dialog.tpl" title=$lng.lbl_promotions content=$smarty.capture.dialog extra="width=100%"}
Save below code as: customer/coupons.php
Code:
<?
/*****************************************************************************\
+-----------------------------------------------------------------------------+
| X-Cart |
| Copyright (c) 2001-2002 Ruslan R. Fazliev. All rights reserved. |
+-----------------------------------------------------------------------------+
| The Ruslan R. Fazliev forbids, under any circumstances, the unauthorized |
| reproduction of software or use of illegally obtained software. Making |
| illegal copies of software is prohibited. Individuals who violate copyright |
| law and software licensing agreements may be subject to criminal or civil |
| action by the owner of the copyright. |
| |
| 1. It is illegal to copy a software, and install that single program for |
| simultaneous use on multiple machines. |
| |
| 2. Unauthorized copies of software may not be used in any way. This applies |
| even though you yourself may not have made the illegal copy. |
| |
| 3. Purchase of the appropriate number of copies of a software is necessary |
| for maintaining legal status. |
| |
| DISCLAIMER |
| |
| THIS SOFTWARE IS PROVIDED BY Ruslan R. Fazliev ``AS IS'' AND ANY |
| EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| DISCLAIMED. IN NO EVENT SHALL Ruslan R. Fazliev OR ITS |
| CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| |
| The Initial Developer of the Original Code is Ruslan R. Fazliev. |
| Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2002 |
| Ruslan R. Fazliev. All Rights Reserved. |
+-----------------------------------------------------------------------------+
\*****************************************************************************/
#
# $Id: coupons.php,v 1.16 2003/01/14 13:43:46 svowl Exp $
#
require "../smarty.php";
require "../config.php";
require "./auth.php";
include "../include/categories.php";
$coupons = func_query("select * from $sql_tbl[discount_coupons] where status_view='Y' and status='A' and expire>".time());
$smarty->assign("coupons", $coupons);
$smarty->assign("main","store_coupons");
$smarty->display("customer/home.tpl");
?>
4
#######################
Modify Existing Files
#######################
TEMPLATE FILE: skin1/customer/home_main.tpl
Place following code:
Code:
{elseif $main eq "store_coupons"}
{include file="customer/coupons.tpl"}
TEMPLATE FILE: skin1/modules/Discount_Coupons/coupons.tpl
REPLACE::
Code:
<form action="coupons.php" method="POST">
<tr><td class=TableHead>Coupon</td><td class=TableHead>Status</td><td class=TableHead>Disc.</td><td class=TableHead>Min.</td><td class=TableHead>Times</td><td class=TableHead colspan=2>Expires</td></tr>
{section name=prod_num loop=$coupons}
<tr>
<td>
{$coupons[prod_num].coupon}
</td>
WITH::
Code:
<form action="coupons.php" method="POST">
<tr><td class=TableHead>Coupon</td><td class=TableHead>Viewable</td><td class=TableHead>Status</td><td class=TableHead>Disc.</td><td class=TableHead>Min.</td><td class=TableHead>Times</td><td class=TableHead colspan=2>Expires</td></tr>
{section name=prod_num loop=$coupons}
<tr>
<td>
{$coupons[prod_num].coupon}
</td>
<td>{$coupons[prod_num].status_view}</td>
<td>
PHP FILE: provider/coupons.php
REPLACE::
Code:
db_query("insert into $sql_tbl[discount_coupons] (coupon, discount, coupon_type, minimum, times, expire, status, provider, productid, categoryid) values ('$coupon_new', '$discount_new', '$coupon_type_new', '$minimum_new', '$times_new', '$expire_new', '$status_new', '$login', '$productid_new', '$categoryid_new')");
WITH::
Code:
db_query("insert into $sql_tbl[discount_coupons] (coupon, discount, coupon_type, minimum, times, expire, status, provider, productid, categoryid, status_view) values ('$coupon_new', '$discount_new', '$coupon_type_new', '$minimum_new', '$times_new', '$expire_new', '$status_new', '$login', '$productid_new', '$categoryid_new', '$status_view')");
What I can't figure out is how to display the Category NAME intead of the category ID on the skin1/customer/coupons.tpl file