Zen Cart Logo
Forums / General Questions / Intercepting order and adding to cart with PHP cURL

Intercepting order and adding to cart with PHP cURL

Locked

Views: 2,510

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
28 Oct 2007, 8:06 AM
#1
jds580s avatar

jds580s

New Zenner

Join Date:
Oct 2007
Posts:
25
Plugin Contributions:
0

Intercepting order and adding to cart with PHP cURL

I have a few unique products that required custom attributes that I couldn't achieve with the standard admin attributes tools.

The solution I'm working on requires the add-to-cart button to point to a form processor I'm writing.

I have it finished enough to test, but it's failing every time. Here is the basic flow

Users submits add to cart button on my custom form
POST is sent to my custom form processor
the form processor works with the data
then POSTS to form to /path-to-folder/zencart/index.php?main_page=product_info&number_of_uploads=0&action=add_product&products_id=#

zen-cart is rejecting the order and I can't figure out why.

The form fields I am submitting seem to be identical to what a standard product page would contain

Array
(
[cart_quantity] => 1
[products_id] => 2
[id] => Array
(
[5] => #
[txt_6] => text
[txt_7] => text
[4] => #
[2] => #
[txt_3] => #
[txt_8] => text
[9] => Array
(
[20] => 20
[22] => 22
[23] => 23
)
)
)

Submitted as multipart data

Any ideas on what I am lacking that zen-cart is expecting in that post?

Thanks!

28 Oct 2007, 11:03 AM
#2
merlinpa1969 avatar

merlinpa1969

Totally Zenned

Join Date:
Mar 2004
Posts:
13,031
Plugin Contributions:
4

Re: Intercepting order and adding to cart with PHP cURL

what exactly were you not able to setup with stock attributes?

28 Oct 2007, 5:07 PM
#3
jds580s avatar

jds580s

New Zenner

Join Date:
Oct 2007
Posts:
25
Plugin Contributions:
0

Re: Intercepting order and adding to cart with PHP cURL

Merlinpa1969:

what exactly were you not able to setup with stock attributes?

You can see the page here
http://noteableyou.com/zencart/index.php?main_page=product_info&products_id=2

I'm doing a few other things behind the scenes, but the one that pushed me in this direction is...
I have about 350 fields (check boxes and text inputs) that get validated and condensed into one field that zen-cart receives. The checkboxes are generated dynamically so this method seemed like the best approach to me.

Just to test I copied all the source from a zen-cart generated page into a plain html page here just to see if it would post
link

Those get added to the cart no problem. So I have a feeling it's something in the way I am formating or sending the data.

Does anyone know of a PHP function that will show the raw data submitted from a form including headers and all so I could compare the two?

Thanks!

29 Oct 2007, 7:04 AM
#4
drbyte avatar

drbyte

Sensei

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

Re: Intercepting order and adding to cart with PHP cURL

Posting to the cart via CURL is going to be pointless because the cart session you create via CURL is only valid for that CURL session, which is completely unrelated to your current browser session.

You'll have to post directly to the cart using the same browser instance as the customer is already using.

29 Oct 2007, 7:39 PM
#5
jds580s avatar

jds580s

New Zenner

Join Date:
Oct 2007
Posts:
25
Plugin Contributions:
0

Re: Intercepting order and adding to cart with PHP cURL

DrByte:

Posting to the cart via CURL is going to be pointless because the cart session you create via CURL is only valid for that CURL session, which is completely unrelated to your current browser session.

You'll have to post directly to the cart using the same browser instance as the customer is already using.

I'm not a security expert so perhaps that is completely the case. I was under the impression that if the cURL script captured the header information (including the sessionID and cookies) from the post the user made and modified the outgoing headers to match that cURL could make a transparent post appearing as if nothing was out of the ordinary.

I may revisit this at some point, but for now I suppose I'll proceed to do things without cURL for the sake of time.

Thanks so much for your input DrByte & Merlinpa1969!