question

bobbygill avatar image
bobbygill asked bobbygill commented

How to trigger launch of app based on inventory item selected?

When I use the Gift Card app it adds a button to the inventory screen called "Gift Card", when I press the "Gift Card" button it automatically triggers the launch of the the Gift Card app to take care of provisioning the card. My question is two fold:

1.) How is the Gift Card app adding the custom inventory button to the Register? Is it just creating a new Inventory item?

2.) How does the Gift Card app automatically trigger when the button from 1.) is pressed? Is it just listening to the MODIFY_ORDER action Intent and detecting that a Gift Card inventory item was selected and then using that to trigger itself to open?

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

bobbygill avatar image bobbygill commented ·

Thanks. When I tap the Gift Card (Variable Amount) inventory button the Register app shows a keyboard that allows me to enter in the amount of the gift card. What is displaying this keypad within the Register app? Is it something that is exposed via our own app or is there a setting on the inventory item that causes the Register app to show this keypad whenever it is selected?

0 Likes 0 ·
Bryanne Vega avatar image
Bryanne Vega answered

These are Intents, you should set up a broadcast listener waiting for a specific intent. Intents are messages sent through the system notifying "Hey, this action happened, here's some extras (extras are for example,: orderID, payment total etc)".

After wards, you can verify the tender type and do your logic from there.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jeffrey Blattman avatar image
Jeffrey Blattman answered

1) The Gift Card app creates an inventory item using InventoryConnector.createLineItem(). However, please note that we are changing this behavior such that gift cards are added to an order as a custom line item, not an explicit line item backed by an inventory item.

2) The keypad that allows you to enter the amount is triggered by the fact that the inventory item is created as variably priced. That means that whenever it's added to an order, the price must be entered at that point. An Item has a PriceType, which among other values can be VARIABLE. You can also create an item of this price type using createLineItem().

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

bobbygill avatar image
bobbygill answered Jeffrey Blattman commented

Thanks Jeff. When does the Gift Card app create the inventory item? Is it done the first time the app launches or is it done as part of the install of the app?

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ commented ·

It verifies it is there and creates it if necessary prior to loading the gift card. Again, don't rely on this fact. It's changing, and it's an implementation detail of our Gift Card app.

0 Likes 0 ·

Welcome to the
Clover Developer Community