Forum Moderators: coopster
The issue is this:
I have a 3'rd party shopping cart for my e-commerce site that has no way for me to see cart activity. Fine, I say, I'll just "intercept" the submit button on my "add to cart" form with a script, write a line to file and then have the script send the form happily on its way and I'll have data I can use to track activity.
Not that simple I've learned. I can set the "add to cart" form to submit to my php script, and use curl to submit the form and pass the POST parameters but the Location URL is still on my site pointing to my script. Because the base url is my site other relative links on the shopping cart now fail, no good. Oh, and yes, the form must be submitted as POST.
So, I say, just do a redirect instead. Nope, works in GET, not in POST (for me anyway).
So I figure I go back to submit the form as POST in curl and then redirect to a "view cart". Of all things, the cart shows OTHER contents, not what I put in. It's as though there are 2 carts now, one for my script submitted form requests and another for browser submitted requests. It must be keying off of something, I thought it would be agent or IP but I'm passing USER_AGENT through in my script.
So, am I missing some really key point here?
I'm an old C/Perl coder, new to PHP so I'm still relying on examples to muddle my way through. I've been quite unable to find a good example of this though, not sure why it seems like a pretty ordinary thing to do.
Can somebody please point me in the right direction? TIA.
perhaps you could use the onclick trigger of the submit button get some javascript to do something...
Thank you for the ideas. I've thought about Javascript, normally I shy away from it in favor of server-side work. It is an idea though...
I don't really know how the 3'rd party cart works exactly, it's a black box to me. On my site is an html form which has hidden variables for things such as item name, price, weight, etc and upon the form submit (POST) the form calls the 3'rd party server, in this a cold fusion script which places the item in the cart and displays a page back that is the cart contents. The shopping cart is typical of hosted carts, it's not on my server, it's on theirs and it takes a basic form POST submittal. There's a different call to do a view cart. I don't know if I can mention the name here since I'm new to the forum and it's not my intention to plug or dis anyone.
The goal is simple, since the POST goes away to another server, the only shot I've got at squirreling away a little intelligence data for myself about items placed in my cart on that other server is to 'intercept' them as they push the add to cart form leaving my server to go to the cart. But I just can't figure out how to do that intercept correctly.
Thank you for your consideration.
Peace,
Ruth