---
# System prepended metadata

title: 活動定時特價

---

# 活動定時特價
## Step 1 這裡可以設定新的series以及設置圖片位置，想看詳細請參略程式碼
![](https://hackmd.io/_uploads/SkuwJHrfp.png)
## Step 2 這裡可以設定新的series以及設置圖片位置，想看詳細請參略程式碼
![](https://hackmd.io/_uploads/ryXjkBrfp.png)
### 額外解釋
若你要設定固定金額的產品，只需要Cost_M or Cost_L
若要設定特價的請cost_custom + offer_cost_custom
```js
$.ajax({
            url: seriesApiPath + series.series_id,
            dataType: 'json',
            success: function (data) {
              const drinkDatas = data.data.drinks

              let show = (series.series_id === seriesID) ? ' show' : ''
              drinkListHtml += '<div class="collapse no-transition' + show + '" id="series' + series.series_id + '"><div class="list-group" id="drinkList">'
              for (let drink of drinkDatas) {
                window['drinkJson' + drink.drink_id] = drink //品項動態變數

                let button = ''
                let offer = false
                if (drink.drink_cost_twd.M !== null) {
                  let drinkCost = 'NT$' + drink.drink_cost_twd.M
                  if (drink.offer.M !== null) {
                    drinkCost = '<del>NT$' + drink.drink_cost_twd.M + '</del> NT$' + drink.offer.M
                    offer = true
                  }

                  button += '<button type="button" class="btn btn-outline-info btn-sm saveDrink" data-drinkid="' + drink.drink_id + '" data-drinksize="M">中杯 ' + drinkCost + '</button>'
                }
                if (drink.drink_cost_twd.L !== null) {
                  let drinkCost = 'NT$' + drink.drink_cost_twd.L
                  if (drink.offer.L !== null) {
                    drinkCost = '<del>NT$' + drink.drink_cost_twd.L + '</del> NT$' + drink.offer.L
                    offer = true
                  }

                  button += '<button type="button" class="btn btn-outline-info btn-sm saveDrink" data-drinkid="' + drink.drink_id + '" data-drinksize="L">大杯 ' + drinkCost + '</button>'
                }
                if (drink.drink_cost_twd.custom !== null) {
                  let drinkCost = 'NT$' + drink.drink_cost_twd.custom
                  if (drink.offer.custom !== null) {
                    drinkCost = '<del>NT$' + drink.drink_cost_twd.custom + '</del> NT$' + drink.offer.custom
                    offer = true
                  }

                  button += '<button type="button" class="btn btn-outline-info btn-sm saveDrink" data-drinkid="' + drink.drink_id + '" data-drinksize="custom">' + drinkCost + '</button>'
                }

                let drinkName = drink.drink_name
                if (drink.offer.description !== null && offer) {
                  drinkName = drink.drink_name + ' (<text class="text-danger">' + drink.offer.description + '</text>)'
                }

                drinkListHtml += '<a class="list-group-item">' + drinkName + '<br><div class="btn-group mt-1" role="group">' + button + '</div></a>'
              }
              drinkListHtml += '</div></div>'

              $('#drink').html(drinkListHtml)

              //$('#top1').scrollLeft(60);

              $('#top1 .carousel').html(seriesListHtml)
            }
          })
```