|
|
@@ -1,5 +1,5 @@
|
|
1
|
1
|
import { reactive } from 'vue'
|
|
2
|
|
-import { FormValidationError } from '@/utils/helpers'
|
|
|
2
|
+import { FormValidationError, ppn } from '@/utils/helpers'
|
|
3
|
3
|
|
|
4
|
4
|
export function useCart(form, initialProducts = []) {
|
|
5
|
5
|
const cart = reactive(initialProducts)
|
|
|
@@ -83,11 +83,9 @@ export function useCart(form, initialProducts = []) {
|
|
83
|
83
|
|
|
84
|
84
|
const totalCartPrice = () => {
|
|
85
|
85
|
const itemPrices = cart.map((product) => {
|
|
86
|
|
- if (form.checkedPpn) {
|
|
87
|
|
- return product.price + product.price * (form.ppn / 100)
|
|
88
|
|
- } else {
|
|
89
|
|
- return product.price
|
|
90
|
|
- }
|
|
|
86
|
+ return form.checkedPpn
|
|
|
87
|
+ ? ppn(product.price, form.ppn) * product.qty
|
|
|
88
|
+ : product.price * product.qty
|
|
91
|
89
|
})
|
|
92
|
90
|
|
|
93
|
91
|
return itemPrices.reduce(
|