Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Where is PHP code for Add-to-cart?

Where is PHP code for Add-to-cart?

Locked

Views: 22,689

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
26 Jul 2007, 6:09 AM
#1
artcoder avatar

artcoder

Zen Follower

Join Date:
Jan 2007
Posts:
166
Plugin Contributions:
0

Where is PHP code for Add-to-cart?

Can someone point to me the PHP code that is executed when the "Add to Cart" button is clicked?

And is there any significance to having the attribute "enctype="multipart/form-data" in the <form> that contains the "add-to-cart" button?

Thanks in advance.

26 Jul 2007, 6:26 AM
#2
drbyte avatar

drbyte

Sensei

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

Re: Where is PHP code for Add-to-cart?

artcoder:

Can someone point to me the PHP code that is executed when the "Add to Cart" button is clicked?Yes, lotsa stuff. Various files in the init_includes folder, the main_cart_actions.php file, the extra_cart_actions folder, application_top, the shopping_cart class, and more.

A better question is ... what are you wanting to accomplish?

artcoder:

And is there any significance to having the attribute "enctype="multipart/form-data" in the <form> that contains the "add-to-cart" button?Yes, That's important in order to handle any uploads that your customers might do using upload-file attributes on your products.

26 Jul 2007, 4:54 PM
#3
artcoder avatar

artcoder

Zen Follower

Join Date:
Jan 2007
Posts:
166
Plugin Contributions:
0

Re: Where is PHP code for Add-to-cart?

Thanks. What I am trying to accomplish is that I have a custom PHP page added to the shop where I put some buttons like the following ...

<form name="mycartpostform" id="mycartpostform" action="[URL="http://www.myeyesadoreyou.com.au/index.php?main_page=shopping_cart&action=add_product"]index.php?main_page=shopping_cart&action=add_product[/URL]" method="post" enctype="multipart/form-data">
<input type="hidden" name="products_id" value="124" />
<input type="image" src="includes/templates/template_default/buttons/english/button_in_cart.gif" alt="Add to Cart" title=" Add to Cart " />          
</form>

where if the user clicks the button, it adds product 124 to cart.

I'm trying to figure out how to re-construct this form so that it adds both product 124 and 125 to cart.

I tried ...

<form name="mycartpostform" id="mycartpostform" action="[URL="http://www.myeyesadoreyou.com.au/index.php?main_page=shopping_cart&action=multiple_products_add_product"]index.php?main_page=shopping_cart&action=multiple_products_add_product[/URL]" method="post" enctype="multipart/form-data">
<input type="hidden" name="products_id" value="124" />
<input type="hidden" name="products_id" value="125" />
<input type="image" src="includes/templates/template_default/buttons/english/button_in_cart.gif" alt="Add to Cart" title=" Add to Cart " />          
</form>

But no luck. It seems to only add the last product number 125.

26 Jul 2007, 5:53 PM
#4
drbyte avatar

drbyte

Sensei

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

Re: Where is PHP code for Add-to-cart?

It should be an array.
The value should be the qty to be adding to the cart.

<input type="hidden" name="products_id[B][124][/B]" value="[B]1[/B]" />
<input type="hidden" name="products_id[B][125][/B]" value="[B]1[/B]" />
27 Jul 2007, 4:36 AM
#5
artcoder avatar

artcoder

Zen Follower

Join Date:
Jan 2007
Posts:
166
Plugin Contributions:
0

Re: Where is PHP code for Add-to-cart?

Thanks! got it.