X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Third Party Add-Ons for X-Cart 4 (https://forum.x-cart.com/forumdisplay.php?f=45)
-   -   Excluding coupns (https://forum.x-cart.com/showthread.php?t=65013)

Dougrun 10-01-2012 12:36 PM

Excluding coupns
 
Im trying to think up a way to exclude coupons from our sale items without getting custom work done. The sale items are already in multiple categories so limiting it to one isn't possible. Any mods or add-ons out there that have coupon exclusions?

totaltec 10-01-2012 01:46 PM

Re: Excluding coupns
 
1 Attachment(s)
Well I think it will require custom code, I haven't seen a module that allows you to exclude products from coupons.

I did this recently, here is my changelog:
Edit /include/func.cart.php
Edit /include/product_modify.php
ALTER TABLE `xcart_products` ADD `coupons_avail` CHAR( 1 ) NOT NULL DEFAULT 'Y' AFTER `discount_avail`
Edit /common_files/main/product_details.tpl

/include/product_modify.php look for:
'discount_avail' => $discount_avail,
After it add:
'coupons_avail' => $coupons_avail,

I am attaching my changed func.cart.php just search it for the word coupons, I believe everything is commented.

/common_files/main/product_details.tpl look for:
PHP Code:

<tr>
  {if 
$geid ne ''}<td width="15" class="TableSubHead"><input type="checkbox" value="Y" name="fields[discount_avail]" /></td>{/if}
  <
td class="FormButton" nowrap="nowrap">{$lng.lbl_apply_global_discounts}:</td>
  <
td class="ProductDetails">
  <
input type="checkbox" name="discount_avail" value="Y"{if $product.productid eq "" or $product.discount_avail eq "Y"checked="checked"{/if} />
  </
td>
</
tr

After it add:
PHP Code:

<tr>
  {if 
$geid ne ''}<td width="15" class="TableSubHead"><input type="checkbox" value="Y" name="fields[coupons_avail]" /></td>{/if}
  <
td class="FormButton" nowrap="nowrap">{$lng.lbl_apply_coupons}:</td>
  <
td class="ProductDetails">
  <
input type="checkbox" name="coupons_avail" value="Y"{if $product.productid eq "" or $product.coupons_avail eq "Y"checked="checked"{/if} />
  </
td>
</
tr


This should give you a checkbox on the product page and the ability to enable/disable coupons for that product. Don;t forget to run the SQL patch from my changeolg above. Be sure you are doing all of this on a dev site rather than your live store.

cflsystems 10-01-2012 01:57 PM

Re: Excluding coupns
 
This may work for you - http://www.cflsystems.com/coupons-extension-for-x-cart.html. It doesn't exclude but allows you to select exact products to apply coupon to

Dougrun 10-01-2012 02:10 PM

Re: Excluding coupns
 
what version is your func.cart.php based on? i see a difference that not commented.

Dougrun 10-01-2012 02:37 PM

Re: Excluding coupns
 
Hmm, it seems to work on the backend but my cart is still applying it to unchecked items. I'l lhave to go through my func.cart.php and find it.

btw, had to add
lbl_apply_coupons


Dougrun 10-02-2012 08:55 AM

Re: Excluding coupns
 
1 Attachment(s)
nevermind, I finally got it working, thanks. attached is the 4.5.2 func.cart.php file needed.

Also, if anyone needs to modify their own cart.php file, search for "coupons_" not just coupon, way too many of those.

totaltec 10-02-2012 09:12 AM

Re: Excluding coupns
 
Glad you got it sorted out. Thanks for providing your solutions/discoveries for the community.

Dougrun 10-19-2012 11:21 AM

Re: Excluding coupns
 
do you think theres anything in this mod that would disable my UPS realtime rates from showing up?

totaltec 10-19-2012 12:50 PM

Re: Excluding coupns
 
I can't imagine there would be, but can't rule it out if nothing else has been changed. Simple solution try reverting the changes you've made and see if it fixes the problem.

Real time rates are notoriously touchy, you never know if it is on your side or theirs.

Dougrun 10-19-2012 12:53 PM

Re: Excluding coupns
 
nevermind, seems i had to re-register the UPS tool in order to get it working again.

Dougrun 10-22-2012 03:43 PM

Re: Excluding coupns
 
fyi, upgrading from gold to gold plus does not effect this mod. even though the "on sale" module places a checkbox on the bottom of the product page, it didnt touch my "apply coupons" checkbox and it still works on the checkout page.

MAPerformance 12-20-2012 09:22 AM

Re: Excluding coupns
 
Quote:

Originally Posted by totaltec
Well I think it will require custom code, I haven't seen a module that allows you to exclude products from coupons.

I did this recently, here is my changelog:
Edit /include/func.cart.php
Edit /include/product_modify.php
ALTER TABLE `xcart_products` ADD `coupons_avail` CHAR( 1 ) NOT NULL DEFAULT 'Y' AFTER `discount_avail`
Edit /common_files/main/product_details.tpl

/include/product_modify.php look for:
'discount_avail' => $discount_avail,
After it add:
'coupons_avail' => $coupons_avail,

I am attaching my changed func.cart.php just search it for the word coupons, I believe everything is commented.

/common_files/main/product_details.tpl look for:
PHP Code:

<tr>
  {if 
$geid ne ''}<td width="15" class="TableSubHead"><input type="checkbox" value="Y" name="fields[discount_avail]" /></td>{/if}
  <
td class="FormButton" nowrap="nowrap">{$lng.lbl_apply_global_discounts}:</td>
  <
td class="ProductDetails">
  <
input type="checkbox" name="discount_avail" value="Y"{if $product.productid eq "" or $product.discount_avail eq "Y"checked="checked"{/if} />
  </
td>
</
tr

After it add:
PHP Code:

<tr>
  {if 
$geid ne ''}<td width="15" class="TableSubHead"><input type="checkbox" value="Y" name="fields[coupons_avail]" /></td>{/if}
  <
td class="FormButton" nowrap="nowrap">{$lng.lbl_apply_coupons}:</td>
  <
td class="ProductDetails">
  <
input type="checkbox" name="coupons_avail" value="Y"{if $product.productid eq "" or $product.coupons_avail eq "Y"checked="checked"{/if} />
  </
td>
</
tr


This should give you a checkbox on the product page and the ability to enable/disable coupons for that product. Don;t forget to run the SQL patch from my changeolg above. Be sure you are doing all of this on a dev site rather than your live store.


I can verify this works like a charm on my 4.4.3 Gold site. I searched Mike's func.cart.php file for "coupons_avail" to find the additional code and added into my file (located at include/func/func.cart.php, not include/func.cart.php as noted). You also need to add a language variable for "lbl_apply_coupons".

Dougrun 12-20-2012 03:05 PM

Re: Excluding coupns
 
just to confirm, this also works on AlteredCarts Onepage Checkout module which I switched to yesterday.

carpeperdiem 08-02-2013 06:14 AM

Re: Excluding coupns
 
I can verify that between Mike's post #2 and Doug's post #5 and #6 - works in 4.5.4.
This is a brilliant patch!

Especially useful if you make gift certificates a PRODUCT -- and you must exclude coupon codes from GC purchases.

Thanks guys!
J

PS - don't forget to run cleanup.php and/or purge your caches.

Dougrun 08-09-2013 02:42 PM

Re: Excluding coupns
 
still works in 4.6 too.

Dougrun 12-20-2013 08:44 AM

Re: Excluding coupns
 
I noticed that I can no longer change the coupon checkbox on the product page with this mod in 4.6.1. I have to manually go in the table and change it. It does stick, it just doesnt take the product pages changes. Any idea where I should look?

The other checkboxes work when i change them, just not this one since the upgrade..

mcanitano 07-30-2014 07:08 AM

Re: Excluding coupns
 
Amazing work! Thanks guys. I can confirm it works on v4.5.5. This is great, as we have a category for clearance items, and people have been "double dipping" by applying coupon codes to clearance items. Not anymore :)

Dougrun 07-31-2014 01:13 PM

Re: Excluding coupns
 
also works in 4.6.4

Dougrun 09-04-2015 12:04 PM

Re: Excluding coupns
 
upgraded to 4.7.2 and this no longer works, I cannot get the func.cart.php file working. It makes the entire store go blank.

mcanitano 09-04-2015 12:56 PM

Re: Excluding coupns
 
Doug, not sure (we don't use 4.7.x) but it may be due to 4.7 using Smarty3? Check into that and see what you can find out

Dougrun 09-04-2015 01:25 PM

Re: Excluding coupns
 
maybe Totaltec can help?

totaltec 09-09-2015 07:21 PM

Re: Excluding coupns
 
Doug,
Got your PM. I'd like to help and have time to look into it, but I'm swamped. Busier than I have ever been.

Dougrun 09-10-2015 07:56 AM

Re: Excluding coupns
 
I seem to recall XC was working on some similar feature regarding applying coupons to products. Any XC people want to chime in on whether a new feature may have disabled our old hack?

Dougrun 09-10-2015 12:47 PM

Re: Excluding coupns
 
I fixed it! Must have been copying too much, i did a side by side comparison and it worked much better than searching for "coupons_"

Works on 4.7.2

Dougrun 02-28-2016 12:48 PM

Re: Excluding coupns
 
this is broken again, and i'm on 4.7.4. I have products that have accept coupons unchecked but xc is applying them. Anyone on 4.7.4 have this working?

Dougrun 02-28-2016 01:51 PM

Re: Excluding coupns
 
its a coupon that gives an absolute $ discount, maybe I need more exclusion lines added? Gotta be in the func.cart.php somewhere.

totaltec 10-09-2018 04:57 PM

Re: Excluding coupns
 
Just followed these exact instructions basically for Version 4.7.6 and it worked beautifully. Nice to find some help from yourself from 6 years ago!

Dougrun 10-10-2018 07:42 AM

Re: Excluding coupns
 
the only problem is it doesnt exclude free shipping coupons. we need to figure that one out.

cherie 10-10-2018 12:39 PM

Re: Excluding coupns
 
Have you tried adding some code for coupon_type is/not free_ship ?

Dougrun 10-10-2018 12:49 PM

Re: Excluding coupns
 
I didnt write any of the code so thats not my expertise.

Dougrun 06-14-2019 07:17 AM

Re: Excluding coupns
 
This is somehow now broken in 4.7.11. all my coupons can now be applied to any item so I need a fix. Anyone willing to work on this?

Dougrun 06-14-2019 08:26 AM

Re: Excluding coupns
 
nevermind, my other site it does work so i'll do a compare and figure out whats up..

Dougrun 10-17-2019 02:54 PM

Re: Excluding coupns
 
i'd love to include (exclude) freeshipping coupon types to the ones excluded, i'm searching in the func,cart,php file but not sure where to add it.


i tried this:
Code:

if (
            !empty($coupon_type)
            && $coupon_type == 'free_ship' && $product['coupons_avail'] != 'Y'
        ) {

            // Apply discount coupon 'Free shipping'

            if (
                $single_mode
                || $provider_for == $discount_coupon_data['provider']
            ) {
                $coupon_discount = $shipping_cost;
                $shipping_cost = 0;
            }
        }



but that excluded every item, even if coupons were checked. The original is missing the
Code:

&& $product['coupons_avail'] != 'Y'
and that allows free shipping no matter what (it does follow the coupon rule though which is a certain section).


All times are GMT -8. The time now is 12:38 PM.

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