Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Externally adding an item to the shopping cart?


Guest

Recommended Posts

Posted

Hi, I have been searching for a while and trying to figure out a way to simply link a button on another part of my site to add a certain item to the oscommerce shopping cart. Are there any contributions out there that can help with this, or is there a simple way to find the link that the "add to cart" button uses in oscommerce for each particular item? Thank you very much for your help in advance, ykol20 :-)

Posted

There is no way to externally link unless you force cookie use.

Posted

I've seen some other sites do it, what is the script that the button uses to add the item to the shopping cart? I basically want that particular button, just moved to a different page proabably in the same directory, not even a completely different site. Then the customer would use the same oscommerce checkout process from that point on. I want to have all of the products in the database and accessible through oscommerce. Then have another few pages displaying the products a little bit nicer in flash and linking the "add to cart" links to their respective oscommerce "add to cart" links. I am not sure if it is possible but I am pretty sure that I've seen other sites do it, unless I am misunderstanding something. Thanks for the reply :-)

Posted

OK...create a form that sends POST data to www.yourdomain.com/product_info.php?action=add_product

 

The logic in application_top.php relies on the GET paramter "action" to determine whether to add, update, buy now, etc. but takes the product_id as POST data.

 

Also, you need to pass a POST id if there is an associated attribute or product option.

 

Good luck!

Posted

I made a script that can do this.

 

Click http://www.a1jewelrystore.com/buy.php/15 for example usage (this links to my "work in progress" site and is not a way to get visitors as it is not yet live!).

 

Download the attached .php file. Upload it to the same level as the rest of your pages. Use it like this:

 

http://www.your-domain.com/buy.php/XX

 

Where XX is the number of the product you want people off-site to put directly into their cart.

 

Ex:

<a target="_blank" href="http://www.a1jewelrystore.com/buy.php/15">Buy Frantic</a>

Posted
OK...create a form that sends POST data to www.yourdomain.com/product_info.php?action=add_product

 

The logic in application_top.php relies on the GET paramter "action" to determine whether to add, update, buy now, etc. but takes the product_id as POST data.

 

Also, you need to pass a POST id if there is an associated attribute or product option.

 

Good luck!

 

 

Thanks, how do I easily find the product id? And could give a few more details? Sorry for all of the questions, I am relatively new to oscommerce and php. Thanks for the help tho...

Posted

The attached code snippet will allow you to link to your shopping cart from off-site. If the product has options, it will display the "product_info.php" page to allow the customer to choose the relevant attributes/options.

 

If the product has no attributes/options, the product is placed directly into the shopping cart.

 

Instructions:

--------------

1/ Download the attached code snippet.

2/ Upload it to your webspace on the same level as your shopping_cart.php, product_info.php etc etc pages.

3/ Link to it like this: http://www.whatever-your-domain-is.com/buy.php/XX or like this:

 

<a href="http://www.whatever-your-domain-is.com/buy.php/XX">Buy my Product</a>

 

4/ Change XX in the above example to whatever product_id you want to use. And obviously put in your correct Domain Name!

5/ Done.

Posted

No problem, it's something I wrote a while back for a client.

 

I have another one which gives an instant memorable URL. Thus:

 

<?php
/*
go.php
Copyright (c) 2004 osCBooks
Released under the GNU General Public License 
*/
require('includes/application_top.php'); 
$id = (integer) substr($_SERVER['PATH_INFO'], 1); 
header("Location: " . HTTP_SERVER . DIR_WS_HTTP_CATALOG . FILENAME_PRODUCT_INFO . "?products_id=" . $id); 
exit; 
?>

 

Usage:

1/ Copy/paste the code into a new file named go.php

2/ Upload the new go.php file to your webspace on the same level as your shopping_cart.php, product_info.php etc etc pages.

3/ Link to it like this: http://www.whatever-your-domain-is.com/go.php/XX

4/ Change XX in the above example to whatever product_id you want to go to. And obviously put in your correct Domain Name!

5/ Done.

 

This is much easier than saying (perhaps to a client on the phone):

 

Sure, see my blue widget at www.my-store.com/product_info.php?products_id=123

 

Now you can say:

Sure, see my blue widget at www.my-store.com/go.php/123
  • 2 years later...
Posted

For some reason I tried this <a href="http://www.zelikovitz.com/buy.php/596">CLICK HERE TO ADD TO CART</a> and it does not add to the cart... I put the buy.php in the root directory . Any ideas?

 

 

The attached code snippet will allow you to link to your shopping cart from off-site. If the product has options, it will display the "product_info.php" page to allow the customer to choose the relevant attributes/options.

 

If the product has no attributes/options, the product is placed directly into the shopping cart.

 

Instructions:

--------------

1/ Download the attached code snippet.

2/ Upload it to your webspace on the same level as your shopping_cart.php, product_info.php etc etc pages.

3/ Link to it like this: http://www.whatever-your-domain-is.com/buy.php/XX or like this:

 

<a href="http://www.whatever-your-domain-is.com/buy.php/XX">Buy my Product</a>

 

4/ Change XX in the above example to whatever product_id you want to use. And obviously put in your correct Domain Name!

5/ Done.

  • 1 year later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...