Overview
When using the API to generate buy buttons, sometimes your images will only have certain products enabled. Normally when using our script in non-api mode, we will only generate the buy buttons that are applicable to the image in question. So if Cards are disabled then we will not present the "Buy Cards" button under those images. When you choose to work in API mode, it is up to you to only show the applicable buy buttons, luckily we have just the thing to make that easy!
How
In order to determine what products are enabled and disabled just use the function FOTOMOTO.API.getImageProducts(img ID,callBackFunction). You can read more about it here.The function returns a hash that looks like the following:
Image Products: {"100":true,"101":true,"102":true,"103":false,"104":false,"105":false,"200":true,"300":false,"400":false,"500":false}Each key value paring maps to a particular Product, if it is enabled it will be true, otherwise it will be false. The codes are found on the function reference page, but are also included here for quick reference:
FOTOMOTO.API.PRINT = 100 (Any Print)
FOTOMOTO.API.PREMIUM = 101
FOTOMOTO.API.FINEART = 102
FOTOMOTO.API.CANVAS = 103
FOTOMOTO.API.FRAMED = 104
FOTOMOTO.API.STICKY = 105
FOTOMOTO.API.ECARD = 200
FOTOMOTO.API.CARD = 300
FOTOMOTO.API.FILE = 400 (Digital Download)
FOTOMOTO.API.SHARE = 500So in the above case, Prints and Cards are enabled while eCards, Files and Sharing are disabled, so you would simply only show the buy buttons for prints and cards.
As a quick reminder the API function calls for the buy prints and buy cards section of our widget are
FOTOMOTO.API.showWindow(FOTOMOTO.API.PRINT, "mainPhoto") and FOTOMOTO.API.showWindow(FOTOMOTO.API.ECARD, "mainPhoto") respecectively.Where the first parameter is simply the product constant from the above table and mainPhoto is the ID of the image in question.
