Skip to content

Commit 651bfdb

Browse files
committed
chore: update price discount
1 parent 27d4147 commit 651bfdb

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

app/pages/app.vue

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,33 @@ async function handleCheckout() {
176176
class="flex-1 md:w-auto w-full"
177177
>
178178
<template #item="{ item }">
179-
{{ item.title }}
180-
181-
<span class="text-gray-500">{{ formatPrice(item.price, item.currency) }} / {{ item.amount }} credits</span>
179+
<span class="text-gray-500">
180+
<template v-if="item.price_discount">
181+
{{ formatPrice(Number(item.price_discount), item.currency) }}
182+
/ {{ item.amount }} {{ $t('credits') }}
183+
184+
<UBadge class="line-through ml-2">Giá gốc:{{ formatPrice(Number(item.price), item.currency) }}</UBadge>
185+
</template>
186+
<template v-else>
187+
{{ formatPrice(Number(item.price), item.currency) }}
188+
/ {{ item.amount }} {{ $t('credits') }}
189+
190+
</template>
191+
</span>
182192
</template>
183193
</USelect>
184194

185195
<UButton id="topup" size="lg" color="neutral" trailing-icon="i-lucide-rocket" class="md:w-auto w-full" @click="handleCheckout">
186196
<b>
187197
{{ $t('Buy') }} {{ selectedPrice?.amount || 0 }} credits
188198
</b>
189-
({{ formatPrice(selectedPrice?.amount || 0, selectedPrice?.currency || 'VND') }})
199+
<template v-if="selectedPrice?.price_discount">
200+
(<span class="line-through">{{ formatPrice(Number(selectedPrice?.price || 0), selectedPrice?.currency || 'VND') }}</span>
201+
{{ formatPrice(Number(selectedPrice?.price_discount || 0), selectedPrice?.currency || 'VND') }})
202+
</template>
203+
<template v-else>
204+
({{ formatPrice(Number(selectedPrice?.price || 0), selectedPrice?.currency || 'VND') }})
205+
</template>
190206
</UButton>
191207
</div>
192208
</UFormField>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@thecodeorigin/nuxt",
33
"type": "module",
4-
"version": "2.4.10",
4+
"version": "2.4.11",
55
"publishConfig": {
66
"registry": "https://registry.npmjs.org",
77
"access": "public"

server/utils/payment/vn/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export async function createPaymentCheckout(
2020

2121
const [productType, productId] = payload.productIdentifier.split(':')
2222

23-
let productInfo: { id: string, price: number, amount: number } | undefined
23+
let productInfo: { id: string, price: number, amount: number, price_discount: number } | undefined
2424

2525
const { createOrder, createPayment, createProviderTransaction } = usePayment()
2626
const { getProductByProductId } = useProduct()
@@ -49,7 +49,7 @@ export async function createPaymentCheckout(
4949
const userPayment = await createPayment(
5050
userOrder.id,
5151
payload.user.id,
52-
Number(productInfo.price),
52+
Number(productInfo.price_discount || productInfo.price),
5353
)
5454

5555
const orderCode = new Date().getTime()

0 commit comments

Comments
 (0)