Editable coupons
This works in my modified 4.0.17 X-Cart. No warranty expressed or implied and all that sort of thing. It allows you to change the amount, times, and most importantly expiration date of a coupon. Changing the type isn't supported because I only use percentage coupons. But it seems pretty clear how to do it. When I finish upgrading to 4.1.19 (or whatever it is by the time I'm done), I'll post the update if no-one else beats me to it.
First, back up your coupons table (or whole DB). Or at least have a browser window open on your current coupon list. When I was developing this, an error led to the expiration time of all coupons being set to Dec 31, 1969. Don't let this happen to you... :) provider/coupons.php: Find Code:
db_query("UPDATE $sql_tbl[discount_coupons] SET status='$v[status]' WHERE coupon='$coupon' $provider_condition"); Change to Code:
$expire_time = mktime(0,0,0,$v[Month],$v[Day],$v[Year]); Now, in skin1/modules/Discount_Coupons/coupons.tpl: Find Code:
<TD align="center">{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}{$lng.lbl_coupon_freeship}{/if}</TD> Change to Code:
<TD align="center" nowrap>{if $coupons[prod_num].coupon_type eq "free_ship"}{$lng.lbl_coupon_freeship}{else}<INPUT type="text" name="posted_data[{$coupons[prod_num].coupon}][discount]" value="{$coupons[prod_num].discount}" size="8">{if $coupons[prod_num].coupon_type eq "absolute"}{$config.General.currency_symbol}{else}%{/if}{/if}</TD> For extra credit, if you would prefer to see newest (or longest time-to-live) coupons at the top of the list, then also in provider/coupons.php: Find Code:
$coupons = func_query("select * from $sql_tbl[discount_coupons] where 1 $provider_condition"); Change to Code:
$coupons = func_query("select * from $sql_tbl[discount_coupons] where 1 $provider_condition order by expire desc"); |
Re: Editable coupons
Any update on this for 4.1.9 at all ? :)
|
Re: Editable coupons
Sorry. Haven't upgraded yet. Is the coupon infrastructure significantly different? There's nothing particularly tricky about this change.
|
Re: Editable coupons
Bad ass, thanks! I am plagued by a tendency to not give my coupons enough times, or listen to the bleeding hearts of procrastinators.
|
Re: Editable coupons
Great mod, thanks for sharing.
Now I can just update the expiration date and have a permanent "Free shipping on Tuesday orders". If the coupon could be made day sensitive instead of date sensitive... it would be perfect. :D/ Any suggestions? |
Re: Editable coupons
Just thought I'd share this... but we were looking for a way to edit coupons (mass edit) to require a minimum for the coupons to be used (we have over 100 coupons active in our store)... so we logged into to phpMyAdmin (our database) and pasted the following code in the SQL field (obviously make sure to change the tablename and tablefield to match your db):
Code:
UPDATE tablename SET tablefield = replace(tablefield, "findstring", "replacestring"); In our case the code basically searches the xcart_discount_coupons table for a value of 0.00 in the minimum field and replaces it with 72.50 (our minimum order value for any coupons to be applied) so our code looked as such: Code:
UPDATE xcart_discount_coupons SET minimum= replace(minimum, "0.00", "72.50"); PLEASE MAKE SURE TO BACKUP YOUR DB before making any changes! Hope this helps! |
All times are GMT -8. The time now is 12:37 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.