Cart Search SDK Embedded
Getting your SDK Key
- To get an API key, book a meeting with us and sign the license agreement. Book a meeting by visiting here
Cart search
Example images
Cart search:
Example checkout:
Minimum: passing name and query
At a minimum, you need to pass your company name and the query. For extra options see "Additional optional query parameters" further down on this page.
Basic query
Basic query is simply a list of items and the quantity you want.
For example:
https://sdk.mealme.ai/cart-search?api=YOUR_NAME&query="Eggs":1,"Milk":1
⚠️ Note: YOUR_NAME will be the name of your company, for sandbox orders use YOUR_NAME-sandbox
Advanced query
With advanced query, you can specify additional parameters such as unit size and package type. The items are passed as an array with objects in JSON format. You may have to encode the query with for example encodeURIComponent
in javascript to make it work for all situations. For readability all the following examples will not be encoded.
For example:
https://sdk.mealme.ai/cart-search?api=YOUR_NAME&query=[{"search_term": "Almond Milk", "unit_size": 32, "unit_measurement": "fl oz", "unit_size_filter": "gte"},{"search_term": "Avocado", "unit_size": 2, "unit_measurement": "pound", "unit_package":"bag"}]
Just the query in a more readable format:
[
{"search_term": "Almond Milk", "unit_size": 32, "unit_measurement": "fl oz", "unit_size_filter": "gte"},
{"search_term": "Avocado", "unit_size": 2, "unit_measurement": "pound", "unit_package":"bag"}
]
The supported unit_size_filter
values are the following.
gt, (is greater than)
gte, (is greater than or equal to)
lt, (is less than)
lte, (is less than or equal to)
eq (is equal to)
If nothing is passed, equality (eq) is the default.
The supported unit_measurement
values are:
gb
gigabyte
lb
lbs
pound
pounds
unitPound
oz
ozs
ounce
ounces
tsp
tsps
teaspoon
teaspoons
tbsp
tbsps
tablespoon
tablespoons
c
cs
cup
cups
g
gs
gm
gms
gram
grams
mg
mgs
milligram
milligrams
kg
kgs
kilogram
kilograms
pinch
l
liter
litre
litres
liters
ml
mls
milliliter
milliliters
qt
qts
quart
quarts
gal
gals
gallon
gallons
pt
pts
pint
pints
fl
floz
fluid ounce
fluid ounces
ct
cts
count
counts
The supported values for unit_package
are:
clove
cloves
sprig
sprigs
stalk
stalks
floret
florets
can
cans
box
boxes
pc
piece
pieces
pk
pack
packs
package
packages
bag
bags
container
containers
jar
jars
rack
racks
ball
balls
basket
baskets
btl
bottle
bottles
family
bundle
bundles
bundled
kit
kits
packet
packets
parcel
parcels
assortment
assortments
batch
batches
unit
units
carton
cartons
crate
crates
bowl
bowls
jug
jugs
tub
tubs
Passing location
If you already have the user's location you can pass that information, this way they would not have to enter their location
Example with location parameters:
Additional optional query parameters
isPickup
- default value of the pickup toggle, true means it's a pickup order, false means it will be a delivery orderisOpen
- default value of the open toggle, true means searching for only open stores, false means to search for all storeshidePickupToggle
- passing true will hide the pickup togglehideOpenToggle
- passing true will hide the open toggletitle
- If passed, it will show a title above the cart search user interfacelogoUrl
- If passed, a logo will be added, in the top left by defaultlogoHeight
- If passed it will change the width of the logo, the default value is 30logoAlignment
- Can be used to change the alignment of the logo, accepted values are left, center, and rightsearchRadius
- Normally we gradually increase the radius until we find enough stores, pass if you want to override this and just do one specific search radius, is capped at 10 milessort
- Can be cheapest, fastest, rating, distance, or relevance. The default value if nothing is passed is relevancefullCartsOnly
- only show full carts, it's defaulted to falseuserId
- Use your own identifier for userId if you want an order to be related to a certain user or groupuserEmail
- Will prefill the email field in checkout if passeduserName
- Will prefill the name field in checkout if passeduserPhone
- Will prefill the phone field in checkout if passeduserApartmentNumber
- Will prefill the apartment number field in checkout if passedcheckoutNotes
- Will prefill the notes field in checkout if passedstoreType
- Passrestaurant
for restaurant items, passgrocery
for grocery items, or leave empty or exclude to search for bothpinCheckoutButton
- If passingtrue
this will pin the checkout button to the bottom element instead of having a floating buttoncombineServiceAndDeliveryFee
- If passingtrue
this will combine both the delivery fee and service fee on checkout, both will be listed under the category "Service fee"
Example embed
<iframe
src='https://sdk.mealme.ai/cart-search?api=YOUR_NAME&query="Eggs":1,"Milk":1'
allow="geolocation; payment"
title="Mealme Web SDK"
style="border: none;height: 100vh;margin-bottom: 0px;position: relative;z-index: 100;margin-top: 40px;width: 100%;">
</iframe>
Capturing events
We fire events that you can catch if you want to read the data.
The events fired from the cart-search checkout flow are the following:
- Checkout success
- Checkout failure
If you want to capture events while having the SDK in an App, please follow these instructions, instead of the web examples given below.
Success event
Code to capture success event
window.onmessage = (event) => {
if (event.data.id === "mealme-checkout-success") {
// Your code using event.data
}
};
Example data for success event:
{
success: true,
orderId: "123",
items: [
{
product_id: "gAAA",
item_name: "NESCAFÉ Dark Roast Instant Coffee",
image: "https://cdn-img.mealme.ai/...",
description: "",
category: "Coffee",
price: 1299,
formatted_price: "$12.99",
upc_codes: [],
unit_size: 10.5,
unit_of_measurement: "oz",
should_fetch_customizations: true,
},
{
product_id: "gAAAA",
item_name: "Lactaid Whole Milk",
image: "https://cdn-img.mealme.ai/...",
description: "",
category: "Milk",
price: 579,
formatted_price: "$5.79",
upc_codes: [],
unit_size: 0.5,
unit_of_measurement: "gal",
should_fetch_customizations: true,
},
],
trackingLink: "https://tracking.mealme.ai/tracking?tracking_id=123",
};
Fail event
Code to capture fail event
window.onmessage = (event) => {
if (event.data.id === "mealme-checkout-fail") {
// Your code using event.data
}
};
Example data for fail event:
{
success: false,
message: "Something went wrong",
}
Updated 7 months ago