Skip to content

Instantly share code, notes, and snippets.

@acidjazz
Created August 30, 2021 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acidjazz/8bdb4bd707368d643b494853acf119d2 to your computer and use it in GitHub Desktop.
Save acidjazz/8bdb4bd707368d643b494853acf119d2 to your computer and use it in GitHub Desktop.
static priceFromCartChoices (rst: Rst, menuId: number, cartChoices: CartChoices, quantity: number) {
const options = this.choicesCombined(rst, menuId).map(c => c.options).flat() as Options
const ids = cartChoices.map(c => c.options).flat()
const selects = options.filter(o => ids.includes(o.id) && o.price) as OptionsWithPrices
const extras = selects.reduce((a, b) => a + b.price, 0)
return (this.menuFromId(rst, menuId).price + extras) * quantity
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment