|
12 | 12 | :alt="product.name" |
13 | 13 | :src="product.image.sourceUrl" |
14 | 14 | /> |
15 | | - |
16 | 15 | <img |
17 | 16 | v-else |
18 | 17 | id="product-image" |
|
24 | 23 | <p class="text-3xl font-bold text-left">{{ product.name }}</p> |
25 | 24 | <div v-if="product.onSale" class="flex"> |
26 | 25 | <p class="pt-1 mt-4 text-3xl text-gray-900"> |
27 | | - {{ product.salePrice }} |
| 26 | + {{ filteredVariantPrice(product.salePrice) }} |
28 | 27 | </p> |
29 | 28 | <p class="pt-1 pl-8 mt-4 text-2xl text-gray-900 line-through"> |
30 | 29 | {{ product.regularPrice }} |
|
44 | 43 | <span class="py-2">Varianter</span> |
45 | 44 | <select |
46 | 45 | id="variant" |
| 46 | + v-model="variationProduct" |
47 | 47 | name="variant" |
48 | 48 | class="block w-64 px-6 py-2 bg-white border border-gray-500 rounded-lg focus:outline-none focus:shadow-outline" |
49 | 49 | > |
50 | | - VARIATION |
| 50 | + <option |
| 51 | + v-for="(variation, index) in product.variations.nodes" |
| 52 | + :key="variation.databaseId" |
| 53 | + :value="variation.databaseId" |
| 54 | + :selected="index === 0" |
| 55 | + > |
| 56 | + {{ variation.name }} |
| 57 | + </option> |
51 | 58 | </select> |
52 | 59 | </p> |
53 | 60 | <div class="pt-1 mt-2"> |
54 | 61 | <CartAddToCartButton |
55 | 62 | v-if="product.variations" |
56 | | - :product="product" |
| 63 | + :product="variationProduct" |
57 | 64 | /> |
58 | 65 | <CartAddToCartButton v-else :product="product" /> |
59 | 66 | </div> |
|
65 | 72 | </template> |
66 | 73 |
|
67 | 74 | <script> |
68 | | -import { stripHTML } from '@/utils/functions' |
| 75 | +import { stripHTML, filteredVariantPrice } from '@/utils/functions' |
69 | 76 |
|
70 | 77 | export default { |
71 | 78 | name: 'ShowSingleProduct', |
72 | 79 | props: { |
73 | 80 | product: { type: Object, required: true }, |
74 | 81 | }, |
75 | | - methods: { stripHTML }, |
| 82 | + data() { |
| 83 | + return { |
| 84 | + // Set default value |
| 85 | + variationProduct: 18, |
| 86 | + } |
| 87 | + }, |
| 88 | +
|
| 89 | + methods: { |
| 90 | + stripHTML, |
| 91 | + filteredVariantPrice, |
| 92 | + }, |
76 | 93 | } |
77 | 94 | </script> |
0 commit comments