Elements
Refill Element

Refill Element

Refill Element an embeddable component for searching and adding products users buy on their own and allow users to add products using the barcode of the product.

elements.create(refill,options?)

Elements.create(refill)

Method parameters

FieldParameterDescription
typerefillThe type of Element being created, which is refill in this case.
optionsObjectOptions for creating the Refill Element.

Option properties

FieldParameterDescription
countryFilterobjectBy default countryFilter is true. It enables users to search products based on the location which country they’re in.Enabled with Foodin provided Google Maps API key. Or you can specify your own google_maps_api to enable Google Maps API with your own key.
allowedCountriesarrayBy default, the Refill Element will display all countries for selection.You can specify which countries are displayed in the Refill Element with a list of two-letter country codes. If only one country is specified, the country field will not display.
allowedStoresarrayBy default, the Refill Element will all stores available in the area.You can specify which stores will be displayed in the Refill Element including their username they have on Foodin
searchobjectSearch option is turned on by default, you can turn it off by passing false parameters.
barcodeScanBooleanBy default search element will display barcode Scan search. Whether you will turn it off depends on your app capabilities and needs.

Search Properties

Search enables customers to search for products within a store or a country, add and update their Pantries straight from your app.

FieldParameterDescription
imagebooleanBy default, images will be displayed in Search. You can choose not to display them to save up on bandwidth.
quantitybooleanBy default, quantity is displayed in the Search. Enables customers to select the quantity of the product they are adding.
brandbooleanBy default, brand is not displayed in the Search. You can display it below the product name.
categorytab gridSpecify the layout how to display categories. By default products will be displayed in tabs depending on their corresponding stores
pricestringBy default, price is displayed in the Search. Enables customers to check prices and update them if they don’t match the stores prices.
imagebooleanBy default, images will be displayed in Search. You can choose not to display them to save up on bandwidth.

Create a Refill Element inside a country

// Create the Refill Element with a country filter
var refillElement = elements.create("refill", {
  countryFilter: {
    googleMapsApi: "YOUR_API_KEY",
  },
});
elements.getElement("refill");

Method parameters

FieldParameterDescription
typerefillThe type of Element being created, which is refill in this case.

Elements.update(options)

element.update(options);

Option properties

FieldParameterDescription
itemobjectFind the item you want to update

Item requests

FieldParameterDescription
upcstringPass the upc number or the rrc number to select the item that needs updating
rrcstring (Optional)Pass the store unique identifier to select a store item if you are updating for that store
pricestring (Optional)Update prices in case they have changed
salePricestring (Optional)Update prices in case they have been purchased on sale
quantityinteger (Optional)Update quantity of products bought
expirationDatestring (Optional)Update latest expiration date of the product

Update search Element

var searchElement = elements.getElement('search');
 
searchElement.update({
  upc:00001221000551,
 
  price: {
    regular:3.44,
    sale: “”
  },
});