Forums / General Questions / Add 2 different products (no attributes) to cart at one time via hardcode link

Add 2 different products (no attributes) to cart at one time via hardcode link

Started by makenoiz on 29 Jul 2013, 10:47 PM · Views: 1,708

Results 1 to 6 of 6
29 Jul 2013, 10:47 PM
#1
makenoiz avatar

makenoiz

Zen Follower

Join Date:
Mar 2006
Posts:
284
Plugin Contributions:
0

Add 2 different products (no attributes) to cart at one time via hardcode link

1.5.1.
Lots and lots of customizations ;}

I am doing some custom coding and coding a link such as this:

mysite.com/index.php?main_page=products_new&action=buy_now&products_id=107230

It works great but I need to add both products_id=107230 and products_id=107231 at the same time.

Can it be done? If I need custom coding... where would you recommend I start.

Thanks!

22 stores and counting! Ive been zenned.

30 Jul 2013, 9:47 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: Add 2 different products (no attributes) to cart at one time via hardcode link

Can you post URLs to these two product_id so we can see the Products and consider the Products and how best to answer this?

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!

1 Aug 2013, 5:19 AM
#3
makenoiz avatar

makenoiz

Zen Follower

Join Date:
Mar 2006
Posts:
284
Plugin Contributions:
0

Re: Add 2 different products (no attributes) to cart at one time via hardcode link

Im on a development server not accessible to the public... but they are basically 1 mit and 1 baseball both from the same category of 'baseball' which is a sub category of parent cat 'sports'. There are no attributes and quantity will always be 1 of each.

dev://mysite.com/index.php?main_page=product_info&cPath=317_321&products_id=107230
dev://mysite.com/index.php?main_page=product_info&cPath=317_321&products_id=107231
parent cat 317 = 'sports'
cat 321 = 'baseball'
products_id=107230 = starter baseball
products_id=107231 = starter mit

I hope this will help you to help me ;)

thank you very much....

P.S. I was thinking of adding a session variable as a flag for the cart page. if the cart page sees that the session Varriable is not null (it would contain the second products_id) then if sessionVarrialbe not Null use javascript to window.location the second buy_now link from the cart. this seems like overkill tho... there must be a simpler way?

22 stores and counting! Ive been zenned.

1 Aug 2013, 5:59 AM
#4
drbyte avatar

drbyte

Sensei

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

Re: Add 2 different products (no attributes) to cart at one time via hardcode link

A few options:

a) consider the Better Together plugin in case it suits your needs and saves you writing code needlessly

b) in a fresh install of Zen Cart, on the product-listing page in any category, the Multiple Add To Cart feature is active by default, and that presents a form that also presents qty input boxes for several items, and has submit buttons which submit those quantities for each of those products, which then triggers the code in the /includes/main_cart_actions.php file (custom changes or additions to that would NOT be put in that file, but instead in the extra_cart_actions folder) to take the submitted product ids and quantities and pass them to the shopping cart class to handle the actual insertion.
So, if your customization is on a non-zen-cart page you could mimic the multiple-item-form-submit.
Or you could intercept the cart-actions processing with your own extra-cart-actions code to check whether a certain product is being added and have it also add another one. For what it's worth I believe this is basically what the better-together plugin does ... but if I'm wrong about that, then what I've just described is how you can do what you've stated.

c) or you could hack up the code and make upgrades more complicated in the future. I don't recommend this if there are more efficient ways to accomplish the same end result.

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

6 Aug 2013, 9:36 PM
#5
makenoiz avatar

makenoiz

Zen Follower

Join Date:
Mar 2006
Posts:
284
Plugin Contributions:
0

Re: Add 2 different products (no attributes) to cart at one time via hardcode link

Yes I try very hard to stay away from 'c'! Our upgrades right now take 2 days and BeyoneCompare is my very very best friend during those 2 days! But the boss is the boss .. ya know.. I dont think 'a' will work with the application so I will put my efforets into 'b'. For some reason I thought Multiple Add To Cart feature was no longer supported... Great idea...

Thanks!

22 stores and counting! Ive been zenned.

10 Aug 2013, 6:14 PM
#6
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,753
Plugin Contributions:
56

Re: Add 2 different products (no attributes) to cart at one time via hardcode link

@makenoiz - see your PM.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.