Zen Cart Logo
Forums / General Questions / Add product to Cart URL?

Add product to Cart URL?

Views: 4,974

Results 1 to 10 of 10
27 Jun 2014, 10:27 AM
#1
aire avatar

aire

New Zenner

Join Date:
Jun 2014
Location:
Alicante
Posts:
15
Plugin Contributions:
0

Add product to Cart URL?

I had Zencart 1.3.8a with a jquery code that throw to "index.php?main_page=product_info&cPath=18&products_id=910&action=add_product" a post form with all the variables and text attributes and the shopping cart recieved the data and added it correctly.

Now I'm trying to migrate to Zencart 1.5.1 and I've modified the jquery code with the securityToken, something that before wasn't needed, to do the same add a product through URL "index.php?main_page=product_info&cPath=18&products_id=910&number_of_uploads=0&action=add_product".
But now it doesn't work the variables are sent, but the shopping cart tells that there's no product in the basket.

And the question are: Can be done what I'm trying in Zencart 1.5.1?
I'm using these fields of the form:
<input type="hidden" name="securityToken" value="444444"></input>
<input type="hidden" name="id[TEXT_PREFIX9]" value="Text"></input>
<input type="hidden" name="id[TEXT_PREFIX5]" value="_-_-_-_-_-_-_-_-_-_-"></input>
<input type="hidden" name="id[6]" value="22"></input>
<input type="hidden" name="id[8]" value="68"></input>
<input type="hidden" name="id[7]" value="67"></input>
<input type="hidden" name="cart_quantity" value="1"></input>
<input type="hidden" name="products_id" value="286"></input>

Am I missing any field?

27 Jun 2014, 1:57 PM
#2
mprough avatar

mprough

Totally Zenned

Join Date:
Nov 2007
Location:
Woodbine, Georgia, United States
Posts:
4,290
Plugin Contributions:
39

Re: Add product to Cart URL?

Not a field, but rather a active session I think... without an active session and cookie set things cannot be added to the cart.

1 Jul 2014, 12:43 PM
#3
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Add product to Cart URL?

Someone (kuroi or DrByte, I forget) posted code a year or two ago that does exactly that, open Zen Cart with a specific product in the cart, so it should be possible.

8 Jul 2014, 8:35 AM
#4
aire avatar

aire

New Zenner

Join Date:
Jun 2014
Location:
Alicante
Posts:
15
Plugin Contributions:
0

Re: Add product to Cart URL?

@gjh42 I thing you are pointing to this threat: http://www.zen-cart.com/showthread.php?96315-Automatically-Add-Products-to-the-cart-via-URL/page2
I've read and using the info in it but it doesn't work in ZC 1.5.1.

@mprough You're right. If I take the security token generated by ZC 1.5.1 of a product, and I paste it in a form of a HTML file like this:

<form action="http://localhost:8888/zc15/index.php?main_page=product_info&cPath=18&products_id=910&number_of_uploads=0&action=add_product" method="post" enctype="multipart/form-data" name="cart_quantity" id="cart_quantity">
<input type="hidden" name="securityToken" value="6f64e3a15e24fa6d55e1813bc6cf99ec"></input>	
<input type="hidden" name="id[TEXT_PREFIX9]" value="Text"></input>
<input type="hidden" name="id[TEXT_PREFIX5]" value="_-_-_-_-_-_-_-_-_-_-"></input>
<input type="hidden" name="id[6]" value="22"></input>
<input type="hidden" name="id[8]" value="68"></input>
<input type="hidden" name="id[7]" value="67"></input>
<input type="hidden" name="cart_quantity" value="1"></input>
<input type="hidden" name="products_id" value="910"></input>

<input name="" type="submit" value="submit"></input>

If I submit that form after pasted the security token in the same browser, ZC 1.5.1 take the product and add it to the cart perfectly.

The problem is related to the relationship between the security token and the cookie.

10 Jul 2014, 9:06 AM
#5
aire avatar

aire

New Zenner

Join Date:
Jun 2014
Location:
Alicante
Posts:
15
Plugin Contributions:
0

Re: Add product to Cart URL?

All right!

Problem solved. I was passing more attributes to ZC 1.5.1 than the attributes the product has.

Solution was:

Include with the ZC 1.5.1 function

zen_draw_hidden_field('securityToken', $_SESSION['securityToken'])
``` the value of securityToken in the form.

<form action="http://localhost:8888/zc15/index.php?main_page=product_info&cPath=18&products_id=910&number_of_uploads=0&action=add_product" method="post" enctype="multipart/form-data" name="cart_quantity" id="cart_quantity"> <input type="hidden" name="securityToken" value="6f64e3a15e24fa6d55e1813bc6cf99ec"></input> <input type="hidden" name="id[TEXT_PREFIX9]" value="Text"></input> <input type="hidden" name="id[TEXT_PREFIX5]" value="_-_-_-_-_-_-_-_-_-_-"></input> <input type="hidden" name="cart_quantity" value="1"></input> <input type="hidden" name="products_id" value="910"></input>

<input name="" type="submit" value="submit"></input>


Make sure you send the correct attributes of the product.

Think, that using the securityToken you can embed swf that send product to the cart.

Enjoy!

THREAT SOLVED!!
10 Jul 2014, 3:10 PM
#6
lat9 avatar

lat9

Administrator

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

Re: Add product to Cart URL?

... or you could have created the form using the function zen_draw_form and it would have added the hidden field for the securityToken as part of its processing.

18 Aug 2014, 8:26 AM
#7
aire avatar

aire

New Zenner

Join Date:
Jun 2014
Location:
Alicante
Posts:
15
Plugin Contributions:
0

Re: Add product to Cart URL?

That's true!

SOLVED!

15 May 2016, 4:38 AM
#8
bushpilot444 avatar

bushpilot444

New Zenner

Join Date:
Apr 2016
Location:
Savannah, Georgia
Posts:
9
Plugin Contributions:
0

Re: Add product to Cart URL?

Maybe my question does not really need a thread of it's own so here goes. I have all my videos and images in the original product id name. I need to match it all in order to automatically program to present the proper images and videos on my product_info_page. I have to make an if statement to see if the video file actually exists and if it does, substitute the produce id which is actually the model number for the file name, then elseif make a statement about no video available if none exists.

How can I get the original product id and put it into, for example, my video code. What variable can I put where I have 'VariableHere in this example? How do I set it up? I use to write perl code but this is a little different. (I had a dollarsign in my little demo here but decided I had better remove it before posting)

<video controls="controls"> <source src="videos/h264/VariableHere.mp4" type="video/mp4"> <source src="videos/webm/VariableHere.webm" type="video/webm"> <source src="movie.ogg" type="videos/ogg/VariableHere.ogg"> Your browser does not support the video tag. </video>

Any help will be greatly appreciated.

15 May 2016, 12:48 PM
#9
lat9 avatar

lat9

Administrator

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

Re: Add product to Cart URL?

bushpilot444:

Maybe my question does not really need a thread of it's own so here goes. I have all my videos and images in the original product id name. I need to match it all in order to automatically program to present the proper images and videos on my product_info_page. I have to make an if statement to see if the video file actually exists and if it does, substitute the produce id which is actually the model number for the file name, then elseif make a statement about no video available if none exists.

How can I get the original product id and put it into, for example, my video code. What variable can I put where I have 'VariableHere in this example? How do I set it up? I use to write perl code but this is a little different. (I had a dollarsign in my little demo here but decided I had better remove it before posting)

<video controls="controls"> <source src="videos/h264/VariableHere.mp4" type="video/mp4"> <source src="videos/webm/VariableHere.webm" type="video/webm"> <source src="movie.ogg" type="videos/ogg/VariableHere.ogg"> Your browser does not support the video tag. </video>

Any help will be greatly appreciated.
You could try delia's Product Extra Fields plugin. That updates your database and the admin-console product-edit page to provide data-entry for various files (and one text-block) that are associated with each product and provides the display/link to those files when the product's product_info page is rendered.

16 May 2016, 8:41 PM
#10
bushpilot444 avatar

bushpilot444

New Zenner

Join Date:
Apr 2016
Location:
Savannah, Georgia
Posts:
9
Plugin Contributions:
0

Re: Add product to Cart URL?

I figured out. I have no idea what the 'correct' way to do this might be, but I have it working just like I wanted with the following;

				      <section id="section-2">
					
				
<?php $videofile="$products_model"; ?>				
<?php $videopath="videos/cc-content/uploads/h264/$videofile.mp4"; ?>
<?php if( file_exists($videopath)){  ?>
			
		<div align="center"><strong><b><i>IndependentAgain.Co Product Videos</i></b></strong></div>
<!--bof Product videos -->
<div align="center">*** Product Demonstration ***</div>
<!--bof Product Name-->
<div align="center"><h4><b><?php echo $products_name; ?></b></h4></div>
<!--eof Product Name-->

<div align="left"><video controls="controls" width="100%" height="auto" preload poster="images/video_images/<?php echo (($products_model !='') ? '' . $products_model . '' : '') . ""; ?>.jpg">>
  <source src="videos/cc-content/uploads/h264/<?php echo (($products_model !='') ? '' . $products_model . '' : '') . ""; ?>.mp4" type="video/mp4">
  <source src="videos/cc-content/uploads/webm/<?php echo (($products_model !='') ? '' . $products_model . '' : '') . ""; ?>.webm" type="video/webm">
  <source src="movie.ogg" type="videos/cc-content/uploads/ogg/<?php echo (($products_model !='') ? '' . $products_model . '' : '') . ""; ?>.ogv">
  Sorry, your browser does not support the video tag.
</video></div>

<?php }else{ ?>
  
		<div align="left"><strong><b><i>Sorry, no videos are available for this product, however, now might be a great time to learn more about the company that manufactures  most of our products.</div><br><div align="center">Introducing Drive DeVilbiss Healthcare</i></b></div><br><div align="left">Drive DeVilbiss Healthcare is one of the fastest growing major manufacturers and distributors of durable medical equipment in the home healthcare, medical/surgical and rehabilitation markets in the United States. We have manufacturing and distribution facilities located throughout the United States, as well as in the United Kingdom, Germany, China, Taiwan, Romania and Canada, and market thousands of products throughout the world. We focus on innovation, functionality, and value to promote independence for the individuals that use our products. Drive DeVilbiss Healthcare exists to enhance the quality of life of the people we touch. Please, watch our video below to learn more about our innovative company.</strong><p></div>

<!--bof Product videos -->
<div align="left"><video controls="controls" preload width="100%" height="auto" poster="images/video_images/drivemedical.jpg">
<source src="videos/cc-content/uploads/h264/drivemedical.mp4" type='video/mp4'>
<source src="videos/cc-content/uploads/webm/drivemedical.webm" type='video/webm' >
<source src="videos/cc-content/uploads/ogg/drivemedical.ogv" type='video/ogg; codecs="theora, vorbis"'/>
<p>Video is not visible, most likely your browser does not support HTML5 video</p>
</video>
</div>

<?php } ?>	

<!--eof Product videos -->
                </section>