Zen Cart Logo
Forums / General Questions / add t ocart link for products with attributes

add t ocart link for products with attributes

Views: 3,203

Results 1 to 6 of 6
26 May 2012, 4:40 AM
#1
joricam avatar

joricam

New Zenner

Join Date:
May 2012
Posts:
7
Plugin Contributions:
0

add t ocart link for products with attributes

hi, I'm hoping someone can help me, I need an url, a link to add product to cart, but with attributes, say the product id is "x" and product has 1 attribute, flavour, wiht 3 posible values (cho, vanilla and strawberry), I need a link that would add the product to the cart with vanilla selected, and then direct you to the shopping cart.

Best Regards
João Mustra

26 May 2012, 9:27 AM
#2
joricam avatar

joricam

New Zenner

Join Date:
May 2012
Posts:
7
Plugin Contributions:
0

Re: add t ocart link for products with attributes

hi, I'm hoping someone can help me, I need an url, a link to add product to cart, but with attributes, say the product id is "x" and product has 1 attribute, flavour, wiht 3 posible values (cho, vanilla and strawberry), I need a link that would add the product to the cart with vanilla selected, and then direct you to the shopping cart.

Best Regards
João Mustra

26 May 2012, 9:45 AM
#3
drbyte avatar

drbyte

Sensei

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

Re: add t ocart link for products with attributes

*Duplicate posts merged. Please don't re-post the same thing over and over again in multiple places.
*

26 May 2012, 9:49 AM
#4
drbyte avatar

drbyte

Sensei

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

Re: add t ocart link for products with attributes

joricam:

I need an url, a link to add product to cart, but with attributes, say the product id is "x" and product has 1 attribute, flavour, wiht 3 posible values (cho, vanilla and strawberry), I need a link that would add the product to the cart with vanilla selected, and then direct you to the shopping cart.
You cannot do that with a URL. Attribute-selections are not auto-selectable via any URL parameters. Only via <form> POST data.

You would need to build a <form> with all the corresponding <input> fields embedded in it with all your predefined values. You would have to reverse-engineer that by studying the dynamically-generated product page and recreating the HTML for your very unique needs. And remember that when you do that you cannot change those attributes in the admin without it affecting the <form> data, and then you'll have to manually rebuild that <form> again after making those edits.

Why are you trying to skip the main product page in Zen Cart, when it already intelligently does all the magic you're looking for? If it's because you want the page to look different, then just style it according to your needs instead of reinventing the wheel.

26 May 2012, 4:21 PM
#5
joricam avatar

joricam

New Zenner

Join Date:
May 2012
Posts:
7
Plugin Contributions:
0

Re: add t ocart link for products with attributes

Hello DrByte, I was exactly looking for you!! Yes its not a problem to use post, I can even use it with jquery post, I really need this badly, it's not to style the page, its so that I can include this in a facebook app that posts open graph objects with a link to add the product directly to the cart, please show me the url structure, the post variables and affected files please.

Best Regards
João Mustra

26 May 2012, 4:47 PM
#6
drbyte avatar

drbyte

Sensei

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

Re: add t ocart link for products with attributes

You can see all the details in the generated HTML page source for your product when you view the product in your store.