Skip to content

Commit 4aa5f0f

Browse files
committed
Category price refactor
1 parent b1ed534 commit 4aa5f0f

File tree

2 files changed

+38
-30
lines changed

2 files changed

+38
-30
lines changed

components/Products/ProductsShowAll.vue

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@
22
<template v-if="allCategoryProducts?.productCategory?.products?.nodes">
33
<section>
44
<div id="product-container" class="flex flex-wrap items-center">
5-
<template v-for="product in allCategoryProducts.productCategory.products.nodes">
6-
<div v-if="product.slug" :key="product.id" class="flex flex-col mt-6 sm:w1/2 md:w-1/3 lg:w-1/4 lg:mr-4">
7-
<NuxtLink class="text-black cursor-pointer hover:underline" :to="{
8-
path: '/product/' + product.slug,
9-
query: { id: product.databaseId },
10-
}">
5+
<template
6+
v-for="product in allCategoryProducts.productCategory.products.nodes"
7+
>
8+
<div
9+
v-if="product.slug"
10+
:key="product.id"
11+
class="flex flex-col mt-6 sm:w1/2 md:w-1/3 lg:w-1/4 lg:mr-4"
12+
>
13+
<NuxtLink
14+
class="text-black cursor-pointer hover:underline"
15+
:to="{
16+
path: '/product/' + product.slug,
17+
query: { id: product.databaseId },
18+
}"
19+
>
1120
<ProductImage :alt="product.name" :src="productImage(product)" />
1221

1322
<div class="flex justify-center pt-3">
@@ -16,23 +25,11 @@
1625
</p>
1726
</div>
1827
</NuxtLink>
19-
<div v-if="product.onSale" class="flex justify-center mt-2">
20-
<div class="text-lg text-gray-900 line-through">
21-
<span v-if="product.variations">
22-
{{ filteredVariantPrice(product.price, "right") }}</span>
23-
<span v-else>{{ product.regularPrice }}</span>
24-
</div>
25-
<div class="ml-4 text-xl text-gray-900">
26-
<span v-if="product.variations">
27-
{{ filteredVariantPrice(product.price) }}</span>
28-
<span v-else>{{ product.salePrice }}</span>
29-
</div>
30-
</div>
31-
<div v-else>
32-
<p class="mt-2 text-xl text-center text-gray-900">
33-
{{ product.price }}
34-
</p>
35-
</div>
28+
<ProductPrice
29+
:product="product"
30+
priceFontSize="normal"
31+
:shouldCenterPrice="true"
32+
/>
3633
</div>
3734
</template>
3835
</div>
@@ -42,19 +39,30 @@
4239
<section>
4340
<div id="product-container" class="flex flex-wrap items-center">
4441
<template v-for="product in allProducts.products.nodes">
45-
<div v-if="product.slug" :key="product.id" class="flex flex-col mt-6 sm:w1/2 md:w-1/3 lg:w-1/4 lg:mr-4">
46-
<NuxtLink class="text-black cursor-pointer hover:underline" :to="{
47-
path: '/product/' + product.slug,
48-
query: { id: product.databaseId },
49-
}">
42+
<div
43+
v-if="product.slug"
44+
:key="product.id"
45+
class="flex flex-col mt-6 sm:w1/2 md:w-1/3 lg:w-1/4 lg:mr-4"
46+
>
47+
<NuxtLink
48+
class="text-black cursor-pointer hover:underline"
49+
:to="{
50+
path: '/product/' + product.slug,
51+
query: { id: product.databaseId },
52+
}"
53+
>
5054
<ProductImage :alt="product.name" :src="productImage(product)" />
5155
<div class="flex justify-center pt-3">
5256
<p class="text-2xl font-bold text-center cursor-pointer">
5357
{{ product.name }}
5458
</p>
5559
</div>
5660
</NuxtLink>
57-
<ProductPrice :product="product" priceFontSize="normal" :shouldCenterPrice="true" />
61+
<ProductPrice
62+
:product="product"
63+
priceFontSize="normal"
64+
:shouldCenterPrice="true"
65+
/>
5866
</div>
5967
</template>
6068
</div>

components/Products/ProductsSingleProduct.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const isLoading = useState("isLoading", () => false);
6565
6666
const cart = useCart();
6767
68-
const selectedVariation = ref(); // TODO Use selectedVariation v-model and implement this functionality to support multiple variants
68+
const selectedVariation = ref(); // TODO Pass this value to addProductToCart()
6969
7070
const props = defineProps({
7171
id: { type: String, required: true },

0 commit comments

Comments
 (0)