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

Global Coupons for X-Cart Pro - Simple Mod

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 03-18-2004, 10:25 AM
 
krazik krazik is offline
 

Member
  
Join Date: May 2003
Posts: 14
 

Default Global Coupons for X-Cart Pro - Simple Mod

Frustraded with the lack of support for a global coupon that works with all providers I wrote my own.

My hack requires you create a provider which I called "globalcoupon". You make the coupons using this provider and a user can use it with any providers products. You can rename this account to something else if you like, but be sure to update the code below.

I am currently on 3.5.2 - I'm not sure if this will work for the pre 3.5s tho it probably should.

** UPDATED Minor Bug Fix 6/6/04 **
File #1
include/func.php -- Line: 900

Original Code
Code:
$discount_coupon_data = func_query_first("select * from $sql_tbl[discount_coupons] where coupon= '$discount_coupon' $provider_condition"); if (!$single_mode and ($discount_coupon_data["provider"] != $provider or empty($products)))

Replace With:
Code:
$discount_coupon_data = func_query_first("select * from $sql_tbl[discount_coupons] where coupon='$discount_coupon' AND ( " . ($single_mode ? "1" : "provider='$provider'") . ($single_mode ? "" : " OR provider='globalcoupon'") .")" ); if (!$single_mode and (($discount_coupon_data["provider"] != "globalcoupon" and $discount_coupon_data["provider"] != $provider) or empty($products)))


File #2
modules/Discount_Coupons/discount_coupons.php

Line: 52
Original Code
Code:
if (!$single_mode) {

Replace With:
Code:
if (!$single_mode and $my_coupon["provider"] != "globalcoupon" ) {

Line: 64
Original Code
Code:
if ((!$single_mode) and ($my_coupon["provider"] != $value["provider"]))

Replace With:
Code:
if ((!$single_mode) and ($my_coupon["provider"] != "globalcoupon") and ($my_coupon["provider"] != $value["provider"]))

Line: ~87
Original Code
Code:
if (!$single_mode and $my_coupon["provider"] != $value["provider"])

Replace With:
Code:
if ((!$single_mode) and ($my_coupon["provider"] != "globalcoupon") and ($my_coupon["provider"] != $value["provider"]))

Line: ~103
Original Code
Code:
if (($single_mode) or ((!$single_mode) and ($my_coupon["provider"] == $value["provider"])))

Replace With:
Code:
if (($single_mode) or ((!$single_mode) and ($my_coupon["provider"] == $value["provider"] or $my_coupon["provider"] == "globalcoupon")))
Reply With Quote
  #2  
Old 03-18-2004, 11:06 AM
  abeight's Avatar 
abeight abeight is offline
 

X-Adept
  
Join Date: Nov 2003
Location: Cleveland, OH
Posts: 479
 

Default

Cool... thanks, Krazik! I'm going to give this a try in the next day or two.
__________________
~ Andrea Beight
Reply With Quote
  #3  
Old 05-29-2004, 06:11 AM
 
bluecat bluecat is offline
 

X-Adept
  
Join Date: Nov 2002
Posts: 674
 

Default

Thank you very much! This should come standard.
__________________
--------------------
X-Cart Gold 4.1.11
Linux/Apache
--------------------
Reply With Quote
  #4  
Old 05-29-2004, 08:33 AM
 
krazik krazik is offline
 

Member
  
Join Date: May 2003
Posts: 14
 

Default

you're both very welcome.

I assume it works for both of you? It's still working great for me.

-Ry
Reply With Quote
  #5  
Old 05-29-2004, 07:19 PM
 
bluecat bluecat is offline
 

X-Adept
  
Join Date: Nov 2002
Posts: 674
 

Default

I actually haven't installed it yet, but will. thanks again.
__________________
--------------------
X-Cart Gold 4.1.11
Linux/Apache
--------------------
Reply With Quote
  #6  
Old 06-06-2004, 12:57 PM
 
krazik krazik is offline
 

Member
  
Join Date: May 2003
Posts: 14
 

Default

Updated the code above to fix a bug.

** NEW CODE **
File #1
include/func.php -- Line: 900

Original Code
Code:
$discount_coupon_data = func_query_first("select * from $sql_tbl[discount_coupons] where coupon= '$discount_coupon' $provider_condition"); if (!$single_mode and ($discount_coupon_data["provider"] != $provider or empty($products)))

Replace With:
Code:
$discount_coupon_data = func_query_first("select * from $sql_tbl[discount_coupons] where coupon='$discount_coupon' AND ( " . ($single_mode ? "1" : "provider='$provider'") . ($single_mode ? "" : " OR provider='globalcoupon'") .")" ); if (!$single_mode and (($discount_coupon_data["provider"] != "globalcoupon" and $discount_coupon_data["provider"] != $provider) or empty($products)))

[quote]
*** OLD CODE - Don't Use ***
File #1
include/func.php -- Line: 900

Original Code
Code:
$discount_coupon_data = func_query_first("select * from $sql_tbl[discount_coupons] where coupon= '$discount_coupon' $provider_condition"); if (!$single_mode and ($discount_coupon_data["provider"] != $provider or empty($products)))

Replace With:
Code:
$discount_coupon_data = func_query_first("select * from $sql_tbl[discount_coupons] where coupon='$discount_coupon' $provider_condition" . ($single_mode ? "" : " OR provider='globalcoupon'")); if (!$single_mode and (($discount_coupon_data["provider"] != "globalcoupon" and $discount_coupon_data["provider"] != $provider) or empty($products)))
[/quote[
Reply With Quote
  #7  
Old 12-01-2004, 10:50 PM
 
teriwinkle teriwinkle is offline
 

Advanced Member
  
Join Date: Aug 2003
Location: Los Angeles
Posts: 63
 

Default Does this act as a gobal discount?

Does this mod create a coupon that acts as a global discount, rather than a coupon? In otherwords, can it create a coupon that can then be applied to any product with the global discounts checked? If so, that is exactly what I am looking for. Please let me know

Thanks!!
__________________
Red Hat Linux/Apache
Reply With Quote
  #8  
Old 02-16-2005, 02:49 PM
 
Danielle Danielle is offline
 

Senior Member
  
Join Date: Jan 2005
Posts: 138
 

Default

Does this work on Pro 4.0.11? And does the customer have to use a coupon code to get the discount?

Thanks!
__________________
Danielle
X-Cart Pro 4.0.10
X-Gift-Registry
X-AOM
Reply With Quote
  #9  
Old 02-16-2005, 02:52 PM
 
krazik krazik is offline
 

Member
  
Join Date: May 2003
Posts: 14
 

Default Re: Does this act as a gobal discount?

Quote:
Originally Posted by teriwinkle
Does this mod create a coupon that acts as a global discount, rather than a coupon? In otherwords, can it create a coupon that can then be applied to any product with the global discounts checked? If so, that is exactly what I am looking for. Please let me know

Thanks!!

No it doesn't do that, just makes coupons that can be used w/ any provider.
Reply With Quote
  #10  
Old 02-16-2005, 02:55 PM
 
krazik krazik is offline
 

Member
  
Join Date: May 2003
Posts: 14
 

Default

Quote:
Originally Posted by Danielle
Does this work on Pro 4.0.11? And does the customer have to use a coupon code to get the discount?

Thanks!

Yes it works on 4.x, we use 4.x now. the line numbers and code is a little different in 4 but pretty much everything else is the same. I didn't bother to document this when I hacked it back into v4.
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 04:20 PM.

   

 
X-Cart forums © 2001-2020