Forums / General Questions / Is there some way to trigger adding a specific product to an open cart?

Is there some way to trigger adding a specific product to an open cart?

Views: 7,683

Results 1 to 12 of 12
27 Jun 2016, 5:40 AM
#1
david_r_1 avatar

david_r_1

New Zenner

Join Date:
Oct 2011
Posts:
42
Plugin Contributions:
0

Is there some way to trigger adding a specific product to an open cart?

We want to run a "buy 2, get product x FREE" promotion, or a "spend y, and get product x FREE" promotion.

We want product X to appear in the cart in response to the customer qualifying, and vanish from the cart if they edit their purchases so they no longer qualify.

This was apparently a really popular request 5+ years ago, since a version of it "buy certain $ amount, get product x FREE added to cart" was the subject of this developers' tutorial:
https://www.zen-cart.com/wiki/index.php/Developers_API_Tutorials#A_Real_World_Example
under the heading "One of the most-often requested features is..."

But I can't find any plugin or other notes since this tutorial was posted to indicate that anyone has successfully done it.

So my two questions are:

  1. Is there some known way to do this?
  2. if not, is there some known issue with this developers' tutorial, so I shouldn't chase down that path?

Thanks very much for any help. Seemed simple, ended up not. How often has that happened? :-)

27 Jun 2016, 6:03 AM
#2
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: Is there some way to trigger adding a specific product to an open cart?

Best to take a look here:http://www.thatsoftwareguy.com/zencart.html
He is the best when it comes to discounts.

1 Jul 2016, 7:13 AM
#3
david_r_1 avatar

david_r_1

New Zenner

Join Date:
Oct 2011
Posts:
42
Plugin Contributions:
0

Re: Is there some way to trigger adding a specific product to an open cart?

Thanks for reaching out, I did start with him. He's great.

But for now, anyway, he doesn't have any one thing or combination of things that does this.

I was hoping someone had successfully executed the example they give in the developer's area, because I'm not a developer and it takes me so long to work my way through learning what I need to know to get one specific thing done... :-)

But I'm guessing that since nobody -- not even thatsoftwareguy -- has done it, there must be some real hurdles.

These forums have saved me countless times, so I haven't given up hope!

1 Jul 2016, 6:21 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Is there some way to trigger adding a specific product to an open cart?

David R:

for now, anyway, he doesn't have any one thing or combination of things that does this.
Judging from http://www.thatsoftwareguy.com/zencart_bogo_bonanza.html it seems the majority of what you've said is indeed available with his plugins. Which specific feature is missing? Perhaps it's more prudent to supplement with something that specifically handles the missing requirement than writing everything from scratch.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

1 Jul 2016, 11:28 PM
#5
david_r_1 avatar

david_r_1

New Zenner

Join Date:
Oct 2011
Posts:
42
Plugin Contributions:
0

Re: Is there some way to trigger adding a specific product to an open cart?

DrByte:

Judging from http://www.thatsoftwareguy.com/zencart_bogo_bonanza.html it seems the majority of what you've said is indeed available with his plugins. Which specific feature is missing? Perhaps it's more prudent to supplement with something that specifically handles the missing requirement than writing everything from scratch.

Thanks Dr. Byte, I thought so, too. But we corresponded about it a bit, and the upshot is that nothing he's currently got will address these things:
a) add a product "Y" to the cart when two products of some type are purchased
b) remove an item from the cart if the buyer changes cart contents and no longer qualifies.

Do you know if anyone ever pushed that tutorial example far enough to know it will work? Has something in the 1.5x generation of Zen Cart made it not a good option?

Thanks again,

2 Jul 2016, 3:55 AM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Is there some way to trigger adding a specific product to an open cart?

David R:

Do you know if anyone ever pushed that tutorial example far enough to know it will work?I know I did, years ago. Not sure if I still have that code around anyplace.
It's very challenging to also have an Admin interface to manage all the possible options. What I'd done was all handled in a PHP file, without any admin-side controls about what products qualified with other products etc. Very rigid implementation. But certainly doable. If you want nice admin controls and switches and fancy dialogs you'll be needing to invest more to provide that.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

2 Jul 2016, 2:03 PM
#7
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,113
Plugin Contributions:
56

Re: Is there some way to trigger adding a specific product to an open cart?

Note, too, that the example should be updated to show the use of the __construct function (that's going to be needed for PHP 7.0 compliance), e.g. changing references like:

<?php
 class myObserver extends base {
   function myObserver() {
     $this->attach($this, array('NOTIFIER_CART_ADD_CART_END'));
   }
...
 }

to

<?php
 class myObserver extends base {
   function [B]__construct[/B]() {
     $this->attach($this, array('NOTIFIER_CART_ADD_CART_END'));
   }
...
 }
2 Jul 2016, 3:33 PM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Is there some way to trigger adding a specific product to an open cart?

lat9:

Note, too, that the example should be updated to show the use of the __construct function (that's going to be needed for PHP 7.0 compliance), e.g. changing references like:

<?php class myObserver extends base { function myObserver() { $this->attach($this, array('NOTIFIER_CART_ADD_CART_END')); } ... } ``` > to > ``` <?php class myObserver extends base { function [B]__construct[/B]() { $this->attach($this, array('NOTIFIER_CART_ADD_CART_END')); } ... } ``` Good point. Updated. Thanks.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

2 Jul 2016, 9:03 PM
#9
david_r_1 avatar

david_r_1

New Zenner

Join Date:
Oct 2011
Posts:
42
Plugin Contributions:
0

Re: Is there some way to trigger adding a specific product to an open cart?

DrByte:

Good point. Updated. Thanks.

Thanks very much!

We don't need any admin interface component to this, and I can repurpose some of the dialog functions we use now. I'll try to get it working from the tutorial as it stands, so I don't introduce any new troubleshooting issues with the __construct function for now.

3 Jul 2016, 11:05 AM
#10
soxophoneplayer avatar

soxophoneplayer

Totally Zenned

Join Date:
Feb 2008
Posts:
534
Plugin Contributions:
0

Re: Is there some way to trigger adding a specific product to an open cart?

Out of curiosity...is the idea to add the free product before or after shipping is calculated? And/or would the customer be able to remove the free item from their cart if they didn't want it, or if there was a shipping cost and they didn't want to pay?

3 Jul 2016, 12:22 PM
#11
david_r_1 avatar

david_r_1

New Zenner

Join Date:
Oct 2011
Posts:
42
Plugin Contributions:
0

Re: Is there some way to trigger adding a specific product to an open cart?

soxophoneplayer:

Out of curiosity...is the idea to add the free product before or after shipping is calculated? And/or would the customer be able to remove the free item from their cart if they didn't want it, or if there was a shipping cost and they didn't want to pay?

I've got the luxury of working on this in the narrow confines of our situation: the added product is free, shipping is free, these items are not taxable.

There is at least one old thread on this topic where the writer was protesting the propriety of adding an item to a customer's cart. I'm sure the questions of tax and shipping would amplify that if someone is trying to make a general purpose contribution.

In what again is our narrow case, the goal is to have this work automatically without requiring any additional steps on the customer's part, and (ideally) to not allow them to trick the system by removing qualifying items during the process. Failing that last, we will have to screen each order during the promotion to be sure it really qualifies.

3 Jul 2016, 1:34 PM
#12
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Is there some way to trigger adding a specific product to an open cart?

In this older post I made I gave some code examples that might be helpful as inspiration for your situation.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.