Zen Cart Logo
Forums / Managing Customers and Orders / coupon code that checks for a product in order

coupon code that checks for a product in order

Locked

Views: 3,563

Results 1 to 14 of 14
This thread is locked. New replies are disabled.
22 May 2007, 10:11 PM
#1
traypup avatar

traypup

New Zenner

Join Date:
May 2007
Posts:
56
Plugin Contributions:
0

coupon code that checks for a product in order

I have spent hours looking around the forums for info to answer my client's questions and this is the only thing I can't find: Client wants to know if there's a way to have a promo or coupon code that will give the customer a discount on the order IF they purchase a specific item. That sounds like it's more trouble than it may be worth, but I thought I'd see what others are doing. I see I can use the Better Together mod to achieve something similar. Is that my only option?

Thanks!

23 May 2007, 4:07 AM
#2
wolfsz avatar

wolfsz

Zen Follower

Join Date:
Mar 2006
Location:
Australia
Posts:
286
Plugin Contributions:
3

Re: coupon code that checks for a product in order

Hi there
We not simply put that item on special? Makes it mush easier for the customer since they don't need coupon etc.

24 May 2007, 12:51 AM
#3
traypup avatar

traypup

New Zenner

Join Date:
May 2007
Posts:
56
Plugin Contributions:
0

Re: coupon code that checks for a product in order

wolfsz:

Hi there
We not simply put that item on special? Makes it mush easier for the customer since they don't need coupon etc.

That's a good question, Wolfsz. It's an online scrapbooking store and I think this is the kind of promotion that a lot of them do on a regular basis. I'll see if anyone else has another suggestion, but I was thinking that my client will just have to check the orders before processing and fulfilling them if they want to do it this way. They can say "add X to your cart, use promo code abc and get a X% discount off your entire order" and then confirm the shopper did so.

thanks for your input!

26 May 2007, 10:28 PM
#4
erm avatar

erm

New Zenner

Join Date:
May 2007
Posts:
14
Plugin Contributions:
0

Re: coupon code that checks for a product in order

Actually, you can.

Goto:
Gift Certificates/Coupons
Coupons Admin
Select you coupon code (or if you don't have one, create one)
After it returns to the admin page, select restrictions
If it's a specific product, select the category name under product restrictions.
Select the product name from the dropdown.
Select allow from the dropdown.
Select add then back.

This should now discount that specific item when the coupon code is entered.

Tony

5 Jun 2007, 7:50 PM
#5
traypup avatar

traypup

New Zenner

Join Date:
May 2007
Posts:
56
Plugin Contributions:
0

Re: coupon code that checks for a product in order

ERM:

This should now discount that specific item when the coupon code is entered.

Tony

Thanks, Tony, but what I really need is a discount for the entire order when that product is added to the cart and the coupon code is added.

6 Jun 2007, 3:57 PM
#6
erm avatar

erm

New Zenner

Join Date:
May 2007
Posts:
14
Plugin Contributions:
0

Re: coupon code that checks for a product in order

So you're discounting the entire order if customer orders product x and no discount off the entire order if they don't order product x?

7 Jun 2007, 1:33 PM
#7
traypup avatar

traypup

New Zenner

Join Date:
May 2007
Posts:
56
Plugin Contributions:
0

Re: coupon code that checks for a product in order

ERM:

So you're discounting the entire order if customer orders product x and no discount off the entire order if they don't order product x?
Yes, that's exactly the plan!

11 Jul 2007, 6:46 PM
#8
kgeoffrey avatar

kgeoffrey

New Zenner

Join Date:
Mar 2007
Posts:
22
Plugin Contributions:
0

Re: coupon code that checks for a product in order

Hi Traypup,

I'm looking for this feature as well. Had any luck?

11 Jul 2007, 6:54 PM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: coupon code that checks for a product in order

The restrictions, at this time, are for the specific products that are restricted and not for the whole order ...

You can customize the code for this, but this is not the easiest peice section of code to work on ...

NOTE: We will be looking at making the Discount Coupons more robust in a future release ...

19 Nov 2008, 3:22 AM
#10
lepton avatar

lepton

New Zenner

Join Date:
Mar 2008
Posts:
1
Plugin Contributions:
0

Re: coupon code that checks for a product in order

I don't know if this is exactly what you wanted but I got around the problem by hacking the template and using JavaScript to enter a coupon code when a certain item was detected in the cart.

in templates\tpl_checkout_payment_default.php after the code block that begins:
$selection = $order_total_modules->credit_selection(); the next line starts an if statement and after the closing brakets of that add this code:

<?php
    }

$products = $_SESSION['cart']->get_products();
  for ($i=0, $n=sizeof($products); $i<$n; $i++) {
              if ($products[$i]['id'] == 19) { // mine was product 19 but this can be set to the ID of the product you want people to buy inorder to get savings
                ?>
				<font color=red>Thank you for your order of specific product!  Your discount will be reflected in the next step.</font>
                 <script language="javascript">
                  document.forms[1].dc_redeem_code.value = 'COUPON_CODE';
                 </script>
				<?php
                break;
              }
     }	
	 
?>

Not very elegant but it's working on my test server.

29 May 2009, 5:22 PM
#11
kgeoffrey avatar

kgeoffrey

New Zenner

Join Date:
Mar 2007
Posts:
22
Plugin Contributions:
0

Re: coupon code that checks for a product in order

I finally synthesized this from others' posts, including lepton's. This definitely works in v. 1.3.0.1. I have not verified any other versions

File to edit:

/includes/modules/order_total/ot_coupon.php
Around line 121 (or 239 if your file has extra carriage returns):

Code to replace:

       for ($i=0; $i<sizeof($products); $i++) {
         if (is_product_valid($products[$i]['id'], $coupon_result->fields['coupon_id']))
           $foundvalid = TRUE;
         }

New code:

         for ($i=0; $i<sizeof($products); $i++) {
// NEW CODE
      if (((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_id','4') < 25)) && ($coupon_result->fields['coupon_id'] == 1)) { 
           $foundvalid = FALSE;
         } else {
// END NEW CODE
         if (is_product_valid($products[$i]['id'], $coupon_result->fields['coupon_id']))
           $foundvalid = TRUE;
         }
// NEW CODE
 }
// END NEW CODE
 

In this example, "4" is the id of the product that must be in the cart in order for the coupon to work; "25" is the minimum quantity of the required product; and "1" is the id of the coupon.

That's it!

19 Nov 2009, 3:58 PM
#12
lextechs avatar

lextechs

Zen Follower

Join Date:
Mar 2005
Location:
Tempe, AZ
Posts:
316
Plugin Contributions:
0

Re: coupon code that checks for a product in order

kgeoffrey:

I finally synthesized this from others' posts, including lepton's. This definitely works in v. 1.3.0.1. I have not verified any other versions

File to edit:

/includes/modules/order_total/ot_coupon.php
Around line 121 (or 239 if your file has extra carriage returns):

Code to replace:

   for ($i=0; $i<sizeof($products); $i++) {
     if (is_product_valid($products[$i]['id'], $coupon_result->fields['coupon_id']))
       $foundvalid = TRUE;
     }
>  
> New code:
>  
> ```php
         for ($i=0; $i<sizeof($products); $i++) {
// NEW CODE
      if (((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_id','4') < 25)) && ($coupon_result->fields['coupon_id'] == 1)) { 
           $foundvalid = FALSE;
         } else {
// END NEW CODE
         if (is_product_valid($products[$i]['id'], $coupon_result->fields['coupon_id']))
           $foundvalid = TRUE;
         }
// NEW CODE
 }
// END NEW CODE
 

In this example, "4" is the id of the product that must be in the cart in order for the coupon to work; "25" is the minimum quantity of the required product; and "1" is the id of the coupon.

That's it!

So do you have to go into this code every time you need to change the product?

17 Feb 2010, 1:04 PM
#13
kmanoj24 avatar

kmanoj24

New Zenner

Join Date:
Feb 2010
Posts:
1
Plugin Contributions:
0

Re: coupon code that checks for a product in order

HI i am using zencart. I need a one coupon code work for all category but the percentages are different for different category

17 Feb 2010, 2:43 PM
#14
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: coupon code that checks for a product in order

Discount Coupons are designed for:

1 Amount Off

2 Percentage Off

3 Free Shipping

plus you can add restrictions for what Categories and/or Products are Allowed or Denied ...

There is not a method for different discounts on a per category basis with the same Discount Coupon, at this time ...