Open URL Internally in PHP Code w/o Open Window - Shop Cart
Posted: Tue Mar 23, 2004 6:27 pm
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!
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!