Forums / Discounts/Coupons, Gift Certificates, Newsletters, Ads / Coupon Restriction by Manufacturer

Coupon Restriction by Manufacturer

Views: 29,813

Results 21 to 40 of 47
6 Nov 2014, 2:46 AM
#21
jsarwar avatar

jsarwar

Zen Follower

Join Date:
Jul 2012
Posts:
347
Plugin Contributions:
0

Coupon Restriction by Manufacturer

Ajeh:

Eeeks! I might have found it ... :eek:

You use prefixes on your database tables?

I tried adding prefix but still same thing. Just to make sure where should I add prefix in following lines:

if ($_GET['build_man'] > 0 && $_POST['products_drop'] == -1) {
          // to insert new products from a given manufacturers_id for a coupon_code that are not already in the table
          // products in the table from the manufacturers_id are skipped
            $new_products_query = "select products_id from products where manufacturers_id = '" . $_GET['build_man'] . "' and products_id not in (select product_id from coupon_restrict where coupon_id = '" . $_GET['cid'] . "')";
            $new_products = $db->Execute($new_products_query);
          }

          if ($_GET['build_man'] > 0 && $_POST['products_drop'] == -2) {
          // to delete existing products from a given manufacturers_id for a coupon_code that are already in the table
          // products in the table from the manufacturers_id are skipped
            $new_products_query = "select products_id from products where manufacturers_id = '" . $_GET['build_man'] . "' and products_id in (select product_id from coupon_restrict where coupon_restrict = '" . $status . "' and coupon_id = '" . $_GET['cid'] . "')";
            $new_products = $db->Execute($new_products_query);
6 Nov 2014, 2:46 AM
#22
ajeh avatar

ajeh

Oba-san

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

Re: Coupon Restriction by Manufacturer

Change line 90 from:

            $new_products_query = "select products_id from products where manufacturers_id = '" . $_GET['build_man'] . "' and products_id not in (select product_id from coupon_restrict where coupon_id = '" . $_GET['cid'] . "')";

to read:

            $new_products_query = "select products_id from " . TABLE_PRODUCTS . " where manufacturers_id = '" . $_GET['build_man'] . "' and products_id not in (select product_id from " . TABLE_COUPON_RESETRICT . " where coupon_id = '" . $_GET['cid'] . "')";

change line 97:

            $new_products_query = "select products_id from products where manufacturers_id = '" . $_GET['build_man'] . "' and products_id in (select product_id from coupon_restrict where coupon_restrict = '" . $status . "' and coupon_id = '" . $_GET['cid'] . "')";

to read:

            $new_products_query = "select products_id from " . TABLE_PRODUCTS . " where manufacturers_id = '" . $_GET['build_man'] . "' and products_id in (select product_id from " . TABLE_COUPON_RESETRICT . " where coupon_restrict = '" . $status . "' and coupon_id = '" . $_GET['cid'] . "')";

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

6 Nov 2014, 2:52 AM
#23
jsarwar avatar

jsarwar

Zen Follower

Join Date:
Jul 2012
Posts:
347
Plugin Contributions:
0

Re: Coupon Restriction by Manufacturer

Ajeh:

Change line 90 from:

        $new_products_query = "select products_id from products where manufacturers_id = '" . $_GET['build_man'] . "' and products_id not in (select product_id from coupon_restrict where coupon_id = '" . $_GET['cid'] . "')";
> 
> to read:
> ```
            $new_products_query = "select products_id from " . TABLE_PRODUCTS . " where manufacturers_id = '" . $_GET['build_man'] . "' and products_id not in (select product_id from " . TABLE_COUPON_RESETRICT . " where coupon_id = '" . $_GET['cid'] . "')";

change line 97:

        $new_products_query = "select products_id from products where manufacturers_id = '" . $_GET['build_man'] . "' and products_id in (select product_id from coupon_restrict where coupon_restrict = '" . $status . "' and coupon_id = '" . $_GET['cid'] . "')";
> 
> to read:
> ```
            $new_products_query = "select products_id from " . TABLE_PRODUCTS . " where manufacturers_id = '" . $_GET['build_man'] . "' and products_id in (select product_id from " . TABLE_COUPON_RESETRICT . " where coupon_restrict = '" . $status . "' and coupon_id = '" . $_GET['cid'] . "')";

Changed but still same error in admin. Log shows following now:

[05-Nov-2014 21:49:47] PHP Fatal error:  1146:Table 'zencart.TABLE_COUPON_RESETRICT' doesn't exist :: select products_id from zen_products where manufacturers_id = '24' and products_id not in (select product_id from TABLE_COUPON_RESETRICT where coupon_id = '10') ==> (as called by) /home/public_html/admin/coupon_restrict.php on line 91 <== in /home/public_html/includes/classes/db/mysql/query_factory.php on line 155
6 Nov 2014, 4:42 AM
#24
ajeh avatar

ajeh

Oba-san

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

Re: Coupon Restriction by Manufacturer

Sorry typo ... change all of the:
TABLE_COUPON_RESETRICT

to be:
TABLE_COUPON_RESTRICT

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

6 Nov 2014, 11:24 AM
#25
jsarwar avatar

jsarwar

Zen Follower

Join Date:
Jul 2012
Posts:
347
Plugin Contributions:
0

Re: Coupon Restriction by Manufacturer

Ajeh:

Sorry typo ... change all of the:
TABLE_COUPON_RESETRICT

to be:
TABLE_COUPON_RESTRICT

Thank you! working now :)

Do you know if this is possible.
Customer apply a coupon code on checkout and a free product get added to their cart per that coupon instead of any discount?

I know right now it is possible if customer add a product to cart and then apply coupon and coupon can make that product free/discounted but is it possible free product get auto added to cart when they apply coupon?

15 Nov 2014, 1:00 AM
#26
jsarwar avatar

jsarwar

Zen Follower

Join Date:
Jul 2012
Posts:
347
Plugin Contributions:
0

Re: Coupon Restriction by Manufacturer

Ajeh:

Sorry typo ... change all of the:
TABLE_COUPON_RESETRICT

to be:
TABLE_COUPON_RESTRICT

Ajeh,
I noticed today there is still an issue. In admin it adds manufacturer product (s) but on live site customer can use coupon for any products by other manufacturers.

Any idea how to apply fix on this?

15 Nov 2014, 1:34 AM
#27
jsarwar avatar

jsarwar

Zen Follower

Join Date:
Jul 2012
Posts:
347
Plugin Contributions:
0

Re: Coupon Restriction by Manufacturer

I did try to add restrict_to_manufacturer, to includes/modules/ordertotal/ot_coupon.php but it shows error on page load. Log shows
"1054:Unknown column 'restrict_to_manufacturer'............"

15 Nov 2014, 1:37 AM
#28
ajeh avatar

ajeh

Oba-san

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

Re: Coupon Restriction by Manufacturer

What are your restrictions set up as on your Discount Coupon?

It sounds like perhaps you did not set:
Top DENY

on the Discount Coupon when you set the Manufacturer Products to ALLOW ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

15 Nov 2014, 1:56 AM
#29
jsarwar avatar

jsarwar

Zen Follower

Join Date:
Jul 2012
Posts:
347
Plugin Contributions:
0

Re: Coupon Restriction by Manufacturer

I think that was the problem and it is working now.

Order total is $118 when I applied coupon it gave error "You must spend at least $50.00 to redeem this coupon"
Can we show brand name in error like You must spend at least $50.00 on abc brand products to redeem this coupon?

15 Nov 2014, 2:09 AM
#30
ajeh avatar

ajeh

Oba-san

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

Re: Coupon Restriction by Manufacturer

The ability to select by Manufacturer is just in the Admin to grab the right Products ... once the restrictions are set, there is nothing about the Discount Coupon to indicate the Manufacturer ...

You would have to do additional custom coding to manage this further ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

15 Nov 2014, 2:13 AM
#31
jsarwar avatar

jsarwar

Zen Follower

Join Date:
Jul 2012
Posts:
347
Plugin Contributions:
0

Re: Coupon Restriction by Manufacturer

Thank you!

I logged back and try to order and again coupon code is applying to other brands products. I checked coupon restriction and top is denied. Any idea what else can be missing?

15 Nov 2014, 2:25 AM
#32
ajeh avatar

ajeh

Oba-san

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

Re: Coupon Restriction by Manufacturer

What are the specific settings on the Restrictions for the Discount Coupon?

NOTE: for something to tell users what is allowed on Minimum Order, I grabbed a piece of code I am building into Zen Cart v16 that you can try ...

Edit the file:
/includes/modules/order_total/ot_coupon.php

and add the code in RED and see if this is somewhat helpful:

// left for total order amount vs qualified order amount just switch the commented lines
//        if ($order_total['totalFull'] < $coupon_result->fields['coupon_minimum_order']) {
        if (strval($order_total['orderTotal']) < $coupon_result->fields['coupon_minimum_order']) {
[B]        $dc_link = ' <a href="javascript:couponpopupWindow(\'' . zen_href_link(FILENAME_POPUP_COUPON_HELP, 'cID=' . $coupon_result->fields['coupon_id']) . '\')">' . $dc_check . '</a>';
[/B]
          $messageStack->add_session('redemptions', sprintf(TEXT_INVALID_REDEEM_COUPON_MINIMUM, $currencies->format($coupon_result->fields['coupon_minimum_order']))[B] . ' ' . $dc_link[/B],'caution');
          $this->clear_posts();
          zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL',true, false));
        }

This should add a link in the message for not enough spent ... see if that at least is more helpful than just the message about the amount ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

15 Nov 2014, 2:45 AM
#33
jsarwar avatar

jsarwar

Zen Follower

Join Date:
Jul 2012
Posts:
347
Plugin Contributions:
0

Re: Coupon Restriction by Manufacturer

Ajeh:

What are the specific settings on the Restrictions for the Discount Coupon?

NOTE: for something to tell users what is allowed on Minimum Order, I grabbed a piece of code I am building into Zen Cart v16 that you can try ...

Edit the file:
/includes/modules/order_total/ot_coupon.php

and add the code in RED and see if this is somewhat helpful:

// left for total order amount vs qualified order amount just switch the commented lines
// if ($order_total['totalFull'] < $coupon_result->fields['coupon_minimum_order']) {
if (strval($order_total['orderTotal']) < $coupon_result->fields['coupon_minimum_order']) {
[B] $dc_link = ' <a href="javascript:couponpopupWindow(\'' . zen_href_link(FILENAME_POPUP_COUPON_HELP, 'cID=' . $coupon_result->fields['coupon_id']) . '\')">' . $dc_check . '</a>';
[/B]

$messageStack->add_session('redemptions', sprintf(TEXT_INVALID_REDEEM_COUPON_MINIMUM, $currencies->format($coupon_result->fields['coupon_minimum_order']))[B] . ' ' . $dc_link[/B],'caution');
$this->clear_posts();
zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL',true, false));
}

> 
> This should add a link in the message for not enough spent ... see if that at least is more helpful than just the message about the amount ...

Code did not make any changes. 

I think coupon is working now. May be browser cookies/cache problem earlier. I will test it again later on as have a conference call right now and will keep you posted. 

Thank you!
15 Nov 2014, 2:59 AM
#34
ajeh avatar

ajeh

Oba-san

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

Re: Coupon Restriction by Manufacturer

Look on the message ... does the Coupon code show at the end of it? If so, click on that ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

15 Nov 2014, 12:38 PM
#35
jsarwar avatar

jsarwar

Zen Follower

Join Date:
Jul 2012
Posts:
347
Plugin Contributions:
0

Re: Coupon Restriction by Manufacturer

Ajeh:

Look on the message ... does the Coupon code show at the end of it? If so, click on that ...

It does not.

15 Nov 2014, 1:33 PM
#36
ajeh avatar

ajeh

Oba-san

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

Re: Coupon Restriction by Manufacturer

Did you also add the code at the end of this line on the message?

          $messageStack->add_session('redemptions', sprintf(TEXT_INVALID_REDEEM_COUPON_MINIMUM, $currencies->format($coupon_result->fields['coupon_minimum_order']))[B] . ' ' . $dc_link[/B],'caution');

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

30 Mar 2015, 1:03 PM
#37
solo_400 avatar

solo_400

Zen Follower

Join Date:
Aug 2009
Posts:
369
Plugin Contributions:
0

Re: Coupon Restriction by Manufacturer

Ajeh:

Not sure if you still need this to add Restrictions based on Manufacturer, but I built this into a future release of Zen Cart and finally had a chance to convert it to work with Zen Cart v151 ...

You might test this and see if it works for you ...

  1. Is it compatible with the 1.5.0 version ?
  2. Is it possible to restrict the using of coupon to at least 2 products in cart for the same manufacturer ?

Thank you very much, your help is really appreciated.

30 Mar 2015, 1:21 PM
#38
ajeh avatar

ajeh

Oba-san

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

Re: Coupon Restriction by Manufacturer

This should work for v1.5 ...

On restricting for two Products for a manufacturer, you would probably need to build something in for that, as there is nothing in there that checks for that, at this time ...

Have you any more details other than you want 2 Products of the same manufacturer?

This add-on allows you to add the Products of a given manufacturer, but it is adding the Products by products_id and there is no reference to the Manufacturer once the coupon is made ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

30 Mar 2015, 2:36 PM
#39
solo_400 avatar

solo_400

Zen Follower

Join Date:
Aug 2009
Posts:
369
Plugin Contributions:
0

Re: Coupon Restriction by Manufacturer

I want to create a "Shop with friends" marketing campaign by offering a discount ( coupon ) for those who buy at least 2 products from a specified manufacturer. The coupon must apply only for more than 1 product for the same manufacturer in cart.
Are you telling that product_id for which coupon apply must be added by hand in restriction section ?

Could this zip do what I need ?

30 Mar 2015, 3:41 PM
#40
ajeh avatar

ajeh

Oba-san

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

Re: Coupon Restriction by Manufacturer

What this does when adding Coupon Restrictions is offer a selection for adding All the Products of a Manufacturer which you can then, if needed, change by deleting or setting to deny ...

What it does not do is count how many Products are in the cart for the manufacturer ... you would need to further customize the code in the ot_coupon.php or something to further control the validation on the specific coupon ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!