X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Global Coupons for X-Cart Pro - Simple Mod (https://forum.x-cart.com/showthread.php?t=6756)

krazik 03-18-2004 10:25 AM

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")))


abeight 03-18-2004 11:06 AM

Cool... thanks, Krazik! :) I'm going to give this a try in the next day or two.

bluecat 05-29-2004 06:11 AM

Thank you very much! This should come standard.

krazik 05-29-2004 08:33 AM

you're both very welcome.

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

-Ry

bluecat 05-29-2004 07:19 PM

I actually haven't installed it yet, but will. ;) thanks again.

krazik 06-06-2004 12:57 PM

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[

teriwinkle 12-01-2004 10:50 PM

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!!

Danielle 02-16-2005 02:49 PM

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

Thanks!

krazik 02-16-2005 02:52 PM

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.

krazik 02-16-2005 02:55 PM

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.


All times are GMT -8. The time now is 10:18 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.