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

Coupon area in admin - modified

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 02-22-2006, 03:52 AM
  amy2203's Avatar 
amy2203 amy2203 is offline
 

X-Wizard
  
Join Date: Jul 2004
Location: Watford, UK
Posts: 1,509
 

Default Coupon area in admin - modified

I've changed the coupon area in my cart as it was laid out really badly from my point of view. With the coupons at the top and the add coupon at the bottom, you had to scroll past them all to add a new one, and that list just gets longer. Also, to display the coupons in the default order meant you had to scroll to the bottom again to see the current/newest ones.

I've changed the php file and the tpl so that now the add coupon section is at the top, and the existing coupons are listed at the bottom, with the newest ones at the top. Note when I say Newest, what I mean is that they are sorted by expiry date which is not quite the same thing. This way I can see what coupons are current.

I offer it here in case anyone want is, but I am a bit of a noob and I can't guarantee that it will run on any other cart. There's not a lot changed, just the template, and the SQL query, but they are not big changes, Please back everything up and take all precautions.

provider/coupons.php

Code:
# # $Id: coupons.php,v 1.21.2.2 2004/03/18 10:41:11 svowl Exp $ # require "./auth.php"; require $xcart_dir."/include/security.php"; include $xcart_dir."/include/categories.php"; # # Use this condition when single mode is disabled # $provider_condition=($single_mode?"":"and provider='$login'"); if ($REQUEST_METHOD=="POST") { while(list($key,$val)=each($HTTP_POST_VARS)) { # # Update discount table # if (strstr($key,"-")) { list($field,$coupon)=split("-",$key); db_query("update $sql_tbl[discount_coupons] set $field='$val' where coupon='$coupon' $provider_condition"); } } # # Add new coupon # if ($coupon_new) { # # Generate timestamp # $expire_new=mktime(0,0,0,$new_Month,$new_Day,$new_Year); $recursive = $recursive?"Y":"N"; switch ($apply_to) { case '': case 'any': $productid_new=0; $categoryid_new=0; break; case 'product': $categoryid_new=0; break; case 'category': $productid_new=0; break; } if (array_pop(func_query_first("SELECT COUNT(*) FROM $sql_tbl[discount_coupons] WHERE coupon='$coupon_new'"))) { $coupon_data = $HTTP_POST_VARS; $coupon_data["expire_new"] = $expire_new; x_session_register("coupon_data"); func_header_location("coupons.php?error=coupon_already_exists"); } db_query("insert into $sql_tbl[discount_coupons] (coupon, discount, coupon_type, minimum, times, expire, status, provider, productid, categoryid, recursive) values ('$coupon_new', '$discount_new', '$coupon_type_new', '$minimum_new', '$times_new', '$expire_new', '$status_new', '$login', '$productid_new', '$categoryid_new', '$recursive')"); } func_header_location("coupons.php"); } if ($mode=="delete") { # # Delete coupon # db_query("delete from $sql_tbl[discount_coupons] where coupon='$coupon' $provider_condition"); func_header_location("coupons.php"); } $coupons = func_query("select * from $sql_tbl[discount_coupons] where 1 $provider_condition ORDER BY expire DESC"); if (x_session_is_registered("coupon_data")) { x_session_register("coupon_data"); $smarty->assign("coupon_data", $coupon_data); x_session_unregister("coupon_data"); } $smarty->assign("coupons", $coupons); $smarty->assign("main","coupons"); @include $xcart_dir."/modules/gold_display.php"; $smarty->display("provider/home.tpl"); ?>

skin1/modules/Discount_Coupons/coupons.tpl

Code:
{* $Id: coupons.tpl,v 1.16.2.2 2004/03/31 06:50:59 svowl Exp $ *} {include file="location.tpl" last_location="Store coupons"} {include file="main/popup_product_js.tpl"} This page allows you to define coupons that you wish to accept for your store. Each coupon allows a customer to receive a discount when he/she orders products from your store. If a customer enters a valid coupon code during checkout, the store will deduct the discount amount from their order total. {capture name=dialog} <font class=AdminTitle>Add new coupon</font> <form action="coupons.php?mode=update" method="POST" name=coupon_form> <table border=0> <tr><td>Coupon # <font class="Star">*</font></td><td><input type=text size=24 name=coupon_new value="{$coupon_data.coupon_new}">{if $smarty.get.error eq "coupon_already_exists"}<font class="ErrorMessage"> &lt;&lt; Already exists</font>{/if}</td></tr> <tr><td>Times to use</td><td><input type=text size=8 name="times_new" value="{$coupon_data.times_new|default:"1"}"></td></tr> <tr><td>Status</td> <td> <select name=status_new> <option value="A"{if $coupon_data.status_new eq "A"} selected{/if}>Active</option> <option value="D"{if $coupon_data.status_new eq "D"} selected{/if}>Disabled</option> </select> </td></tr> <tr><td>Discount</td><td><input type=text size=24 name=discount_new value="{if $coupon_data.discount_new}{$coupon_data.discount_new}{else}0.00{/if}"></td></tr> <tr><td>Coupon type</td> <td> <select name=coupon_type_new> <option value="absolute"{if $coupon_data.coupon_type_new eq "absolute"} selected{/if}>{$config.General.currency_symbol} off</option> <option value="percent"{if $coupon_data.coupon_type_new eq "percent"} selected{/if}>% off</option> <OPTION value="free_ship"{if $coupon_data.coupon_type_new eq "free_ship"} selected{/if}>Free shipping</OPTION> </select> </td></tr> <tr><td>Expires</td> <td> {math equation="x+1" x=$config.Company.end_year assign="endyear"} {html_select_date prefix="new_" time=$coupon_data.expire_new start_year=$config.Company.start_year end_year=$endyear month_format="%b"} </td></tr> <TR> <TD valign=top>Apply to</TD> <TD> <table border=0> <tr><td valign=top><INPUT type=radio name=apply_to value="any"{if $coupon_data.apply_to eq "" or $coupon_data.apply_to eq "any"} checked{/if}></td><td>order subtotal, {$config.General.currency_symbol} <input type=text size=24 name=minimum_new value="0.00"></td></tr> <tr><td valign=top><INPUT type=radio name=apply_to value="product"{if $coupon_data.apply_to eq "product"} checked{/if}></td><td>one product <INPUT type=hidden name="productid_new" value="{$coupon_data.productid_new}"><INPUT type=text readonly size=24 name="productname" value="{$coupon_data.productname}"><INPUT type=button onClick="javascript:popup_product('coupon_form.productid_new','coupon_form.productname');" value="Browse"></td></tr> <tr><td valign=top><INPUT type=radio name=apply_to value="category"{if $coupon_data.apply_to eq "category"} checked{/if}></td><td>category <SELECT name=categoryid_new> {section name=cats loop=$allcategories} <OPTION value="{$allcategories[cats].categoryid}">{$allcategories[cats].category}</OPTION> {/section} </SELECT> with subcategories <input type=checkbox name="recursive"{if $coupon_data.recursive} checked{/if}> </td> </tr> </table> </table> Note: "Free shipping" type coupon applies to the entire cart if one or more products in cart or the order subtotal meet the conditions upon which the coupon should be applied. <input type="submit" value="Add coupon"> </form> <hr size=1 noshade> {if $coupons ne ""} <table width="100%" border=0> <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> <td> <select name="status-{$coupons[prod_num].coupon}"> <option value=A {if $coupons[prod_num].status eq "A"}selected{/if}>Active</option> <option value=D {if $coupons[prod_num].status eq "D"}selected{/if}>Disabled</option> <option value=U {if $coupons[prod_num].status eq "U"}selected{/if}>Used</option> </select> </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>{include file="currency.tpl" value=$coupons[prod_num].minimum}</td> <td align=center>{$coupons[prod_num].times_used}/{$coupons[prod_num].times}</td> <td nowrap> {$coupons[prod_num].expire|date_format:$config.Appearance.date_format} </td> <td><input type="button" value="Delete" onClick="document.location='coupons.php?mode=delete&coupon={$coupons[prod_num].coupon}'"></td> </tr> <tr> <td colspan=7> This coupon applies 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}{if $coupons[prod_num].recursive eq "Y"} and its subcategories{/if} {else} greater than {include file="currency.tpl" value=$coupons[prod_num].minimum} {/if} </td> </tr> {/section} <tr> <td></td><td colspan=5><input type=submit value="Update"></td> </tr> </form> </table> <hr size=1 noshade> {/if} {/capture} {include file="dialog.tpl" title="Store coupons" content=$smarty.capture.dialog extra="width=100%"}

hth
__________________
X-Cart version 5 (Previously 3.5-4)

Previous Versions included
BCSE Reward Points Mod
Altered Cart On Sale Mod
Wordpress Plugin

Please don't PM me for support. I help where I can on the forum and your question will more likely be answered there.

Shout me a Coffee!
Reply With Quote
  #2  
Old 02-22-2006, 04:22 AM
  shan's Avatar 
shan shan is offline
 

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

Default

Thats a first, a custom mod not in the custom mods forum instead of the other way round

if anyone else tests this post back how you get on
__________________
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 02-22-2006, 04:24 AM
  amy2203's Avatar 
amy2203 amy2203 is offline
 

X-Wizard
  
Join Date: Jul 2004
Location: Watford, UK
Posts: 1,509
 

Default

Sorry,

trying to do a few things at once
__________________
X-Cart version 5 (Previously 3.5-4)

Previous Versions included
BCSE Reward Points Mod
Altered Cart On Sale Mod
Wordpress Plugin

Please don't PM me for support. I help where I can on the forum and your question will more likely be answered there.

Shout me a Coffee!
Reply With Quote
  #4  
Old 09-02-2010, 12:17 AM
 
Learner Learner is offline
 

X-Adept
  
Join Date: Dec 2008
Posts: 807
 

Default Re: Coupon area in admin - modified

Hi amy will it work on x cart Pro 4.3.x versions and controlled from admin??
__________________
4.6.1 Platinum


Reply With Quote
  #5  
Old 09-03-2010, 12:29 AM
  amy2203's Avatar 
amy2203 amy2203 is offline
 

X-Wizard
  
Join Date: Jul 2004
Location: Watford, UK
Posts: 1,509
 

Default Re: Coupon area in admin - modified

Sorry I don't know, this was probably for a 3.x branch looking at the date, and I don't have this mod myself at the moment on my 4.1 version, I'd forgotten all about it.

Don't know what you mean by 'controlled by admin' , this just displayed the admin coupon page differently,
__________________
X-Cart version 5 (Previously 3.5-4)

Previous Versions included
BCSE Reward Points Mod
Altered Cart On Sale Mod
Wordpress Plugin

Please don't PM me for support. I help where I can on the forum and your question will more likely be answered there.

Shout me a Coffee!
Reply With Quote
  #6  
Old 09-03-2010, 09:30 PM
 
Learner Learner is offline
 

X-Adept
  
Join Date: Dec 2008
Posts: 807
 

Default Re: Coupon area in admin - modified

I want say about x cart pro ...
__________________
4.6.1 Platinum


Reply With Quote
  #7  
Old 09-18-2010, 11:33 AM
 
lilypad lilypad is offline
 

Advanced Member
  
Join Date: Apr 2007
Posts: 40
 

Default Re: Coupon area in admin - modified

would love to know if this works in 4.x
__________________
Version 4.7.4
Using reBOOT theme
www.the-lilypad.com
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 09:19 AM.

   

 
X-Cart forums © 2001-2020