View Single Post
  #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