Modify add to cart include file

General ShopSite user discussion

Modify add to cart include file

Postby malljess » Mon Nov 28, 2011 9:18 pm

I will be selling products on my site as well as be an affiliate site for other sites. There will be times I want to sell the item on my site and other times when the buyer will be redirected to another site.

I have figured out how to route the buyer to either add product to cart or be referred to an affiliate site - depending on product.

QUESTION: How do I modify the add to cart include file so when the buyer clicks on the button it will refer him/her to the affiliate website. I am storing the affiliate website URL in [-- PRODUCT.field1 --] tag. I figured how to refer it with a <a href="[-- PRODUCT.field1 --]"> BUY EBOOK. But I want the BUY EBOOK in a button like the add to cart button. I know this is probably an easy code but having trouble with it.

Thanks.
malljess
 
Posts: 50
Joined: Sat Oct 22, 2011 7:38 am

Re: Modify add to cart include file

Postby Jim » Tue Nov 29, 2011 10:29 am

Unless the other site is also running ShopSite you would need to find out how their shopping cart does the add to cart. Different carts function differently. I'm not sure how many of them even have a feature like the Order Anywhere links in ShopSite.

If the other site is running ShopSite then you would need to get the info for the add to cart button for that store. You would need the url to the shopping cart, storeid, product id or sku and what ever image/text you are using for the add to cart button.
Since the normal template tags used for this data are for your store, you would need to use other product fields to contain this data.
The Order Anywhere links look like this if you have an sku:
Code: Select all
<a href="URL_TO_ORDER.CGI?storeid=ENCRYPTED_STORE_ID&dbname=products&sku=PRODUCT_SKU&function=add"><img src="URL_TO_BUTTON_IMAGE" border="0" alt="Add To Cart"></a>

or like this if you have a product id:
Code: Select all
<a href="URL_TO_ORDER.CGI?storeid=ENCRYPTED_STORE_ID&dbname=products&itemnum=PRODUCT_ID&function=add"><img src="URL_TO_BUTTON_IMAGE" border="0" alt="Add To Cart"></a>

So your would need to either add the values for the UPPERCASE data above to some of the Extra product fields or put the entire thing into one of the product fields and modify your template to use those fields.
The code to determine if a product is from your site or the other site could be done by checking the value in one of the extra product fields.
Code: Select all
[-- IF PRODUCT.FIELD1 "" --]
this is on your site since the product field 1 is blank so do the normal code here
[-- ELSE --]
<a href="[-- PRODUCT.FIELD1 --]?storeid=[-- PRODUCT.FIELD2 --]&dbname=products&sku=[--PRODUCT.FIELD3 --]&function=add"><img src="[-- OUTPUT_DIRECTORY_URL --]/media/buy_ebook.jpg" border="0" alt="Add To Cart"></a>
[-- END_IF --]

You would need to configure the product extra fields so that Field 1 contains the complete url to order.cgi in the other store, Field 2 contains the other store's storeid (preferable the encrypted version), Field 3 contains the sku, and you would need to create an image for the BUY EBOOK and upload it to the image directory for your store (note: I called it buy_ebook.jpg in the code above so change if necessary). The section just after [-- IF PRODUCT.FIELD1 "" --] would contain what is currently used to generate the add to cart buttons.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah


Return to User Forum

Who is online

Users browsing this forum: No registered users and 133 guests