Page 1 of 1

Open URL Internally in PHP Code w/o Open Window - Shop Cart

Posted: Tue Mar 23, 2004 6:27 pm
by drsmartman
Hi All,

I have an off-site shopping cart that I want to inegrate with my site. In it's simplest form, I would simply have a link to a product and the user would be taken off-site to my shopping cart. However, I'd like to integrate a form to allow multiple purchases to happen at once. To do this, I need to a.) hit each URL to assign each specific product to the shopping cart, then b.) put a checkout on my site that brings them to the off-site URL for payment.

I used the code below just to test, but after accessing the link, it didn't work....In production, this file would receive a POST message with any products selected.....(e.g. Product 1, Product 2)

<?php

//fopen()
fopen("link to product","rb");

// or I used file_get_contents()
file_get_contents("link to product");

?>

<a href="link to cart checkout">checkout</a>

When I do this process manually, it works, but this very simple example will not work. I also got it to work in javascript, but want to do this on the server-side. Any ideas?

By the way, by working I mean I access the product URL (or several of them) then go to the main checkout URL and all of my products are listed. My assumption is that the offline site uses cookies or sessions...would 'fopen()' of 'file_get_contents()' not set the cookie? How come I can in Javascript? I guess my question is a.) how can I open a page in PHP without opening a window, but setting a cookie from that URL or b.) another way around this?

Thanks in advance!

Posted: Tue Mar 23, 2004 6:34 pm
by tim
Seems (sorry to be such a generic answer but I have to leave soon) that you should intergrate a MySQL database to store the products in your cart and manage to imply sessions.

I think those would be your best ways, correct me if i'm wrong anyone.

again sorry i am not going into detail

Posted: Tue Mar 23, 2004 6:40 pm
by drsmartman
Yeah, I think my question wasn't too clear, but that's not what I'm looking for. We already have another site that acts as a shopping cart/checkout system. So, in order for me to add multiple products to one checkout, I need to access a URL for each product. However, it is not very usable to buy one product at a time so when the customer clicks "checkout" they leave my site and see all of the items listed in their shopping cart. Essentially, I just need something on the server-side (PHP) that acts like 'document.open()' in javascript (with parameters for NOT opening a window). I thought 'fopen()' or 'file_get_contents()' would do the trick.....

thanks anyway

Posted: Tue Mar 23, 2004 7:31 pm
by drsmartman
I guess one of the main problems is because accessing those links sets a cookie value. By attempting to do this through PHP, the browser never accesses the cookie. Ugh....anyway around this dilemna?

Posted: Tue Mar 23, 2004 7:34 pm
by d3ad1ysp0rk
iframes? :\

can't think of much.. too bad the checkout isn't on your site.. and I don't know why it isnt.. but too bad :P

Posted: Tue Mar 23, 2004 7:42 pm
by drsmartman
I tried to find if there was just a big URL I could pass with all of the product IDs/quantities, but nothing going. Oh, and the cookie thing IS the problem. No, the shopping cart software is no on site. For example, clicking a product buy button would theoretically go from my site to http://othersite.com/product=xyz, then to checkout. However, instead of only having product xyz, I'd like to have abc, def, etc....the other site accomplishes this through cookies. Back to the drawing board....