@teamnovu/kit-shopware-composables 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Schemas
|
|
1
|
+
import { Schemas } from '../../query/types/operations';
|
|
2
2
|
import { ComputedRef, Ref } from 'vue';
|
|
3
|
+
import { BrandedSchema } from '../types/schema';
|
|
3
4
|
import { TierPrice } from '@shopware/helpers';
|
|
4
5
|
/**
|
|
5
6
|
* The purpose of the `useProductPrice` function is to abstract the logic
|
|
@@ -9,53 +10,13 @@ import { TierPrice } from '@shopware/helpers';
|
|
|
9
10
|
* @category Product
|
|
10
11
|
*/
|
|
11
12
|
export declare function useProductPrice(product: Ref<Schemas['Product'] | undefined>): {
|
|
12
|
-
price: ComputedRef<
|
|
13
|
-
apiAlias: "calculated_price";
|
|
14
|
-
calculatedTaxes: {
|
|
15
|
-
apiAlias: "cart_tax_calculated";
|
|
16
|
-
price: number;
|
|
17
|
-
tax: number;
|
|
18
|
-
taxRate: number;
|
|
19
|
-
}[];
|
|
20
|
-
hasRange: boolean;
|
|
21
|
-
listPrice: components["schemas"]["CartListPrice"] | null;
|
|
22
|
-
netPrice: number;
|
|
23
|
-
positionPrice: number;
|
|
24
|
-
quantity: number;
|
|
25
|
-
rawTotal: number;
|
|
26
|
-
referencePrice: components["schemas"]["CartPriceReference"] | null;
|
|
27
|
-
regulationPrice: {
|
|
28
|
-
apiAlias?: "cart_regulation_price";
|
|
29
|
-
price?: number;
|
|
30
|
-
} | null;
|
|
31
|
-
taxRules: {
|
|
32
|
-
name?: string;
|
|
33
|
-
taxRate?: number;
|
|
34
|
-
}[];
|
|
35
|
-
taxStatus: "net" | "tax-free";
|
|
36
|
-
totalPrice: number;
|
|
37
|
-
unitPrice: number;
|
|
38
|
-
variantId?: string | null;
|
|
39
|
-
} | undefined>;
|
|
13
|
+
price: ComputedRef<BrandedSchema<"CalculatedPrice"> | undefined>;
|
|
40
14
|
totalPrice: ComputedRef<number | undefined>;
|
|
41
15
|
unitPrice: ComputedRef<number | undefined>;
|
|
42
16
|
displayFromVariants: ComputedRef<number | false | undefined>;
|
|
43
17
|
displayFrom: ComputedRef<boolean>;
|
|
44
18
|
tierPrices: ComputedRef< TierPrice[]>;
|
|
45
|
-
referencePrice: ComputedRef<
|
|
46
|
-
apiAlias: "cart_price_reference";
|
|
47
|
-
hasRange: boolean;
|
|
48
|
-
listPrice: components["schemas"]["CartListPrice"] | null;
|
|
49
|
-
price?: number;
|
|
50
|
-
purchaseUnit?: number;
|
|
51
|
-
referenceUnit?: number;
|
|
52
|
-
regulationPrice: {
|
|
53
|
-
apiAlias?: "cart_regulation_price";
|
|
54
|
-
price?: number;
|
|
55
|
-
} | null;
|
|
56
|
-
unitName: string;
|
|
57
|
-
variantId?: string | null;
|
|
58
|
-
} | null | undefined>;
|
|
19
|
+
referencePrice: ComputedRef<BrandedSchema<"CartPriceReference"> | null | undefined>;
|
|
59
20
|
isListPrice: ComputedRef<boolean>;
|
|
60
21
|
regulationPrice: ComputedRef<number | undefined>;
|
|
61
22
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamnovu/kit-shopware-composables",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "A collection of composables for the Shopware API",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"@tanstack/vue-query": "^5.85.3",
|
|
19
19
|
"vue": "^3.0.0",
|
|
20
|
-
"@teamnovu/kit-shopware-api-client": "0.0.
|
|
20
|
+
"@teamnovu/kit-shopware-api-client": "0.0.11"
|
|
21
21
|
},
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
* https://github.com/shopware/frontends/blob/main/packages/composables/src/useProductPrice/useProductPrice.ts
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { Schemas } from '
|
|
6
|
+
import type { Schemas } from '../../query/types/operations'
|
|
7
7
|
import { getProductTierPrices } from '@shopware/helpers'
|
|
8
8
|
import type { ComputedRef, Ref } from 'vue'
|
|
9
9
|
import { computed } from 'vue'
|
|
10
|
+
import type { BrandedSchema } from '../types/schema'
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* The purpose of the `useProductPrice` function is to abstract the logic
|
|
@@ -19,20 +20,20 @@ export function useProductPrice(
|
|
|
19
20
|
product: Ref<Schemas['Product'] | undefined>,
|
|
20
21
|
) {
|
|
21
22
|
const _cheapest: ComputedRef<
|
|
22
|
-
|
|
23
|
+
BrandedSchema<'Product'>['calculatedCheapestPrice'] | undefined
|
|
23
24
|
> = computed(() => product.value?.calculatedCheapestPrice)
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* calculatedPrices are used for product with tier prices
|
|
27
28
|
*/
|
|
28
|
-
const _real: ComputedRef<
|
|
29
|
+
const _real: ComputedRef<BrandedSchema<'CalculatedPrice'> | undefined> = computed(
|
|
29
30
|
() =>
|
|
30
31
|
(product.value?.calculatedPrices?.length ?? 0) > 0
|
|
31
32
|
? product.value?.calculatedPrices?.[0]
|
|
32
33
|
: product.value?.calculatedPrice,
|
|
33
34
|
)
|
|
34
35
|
const referencePrice: ComputedRef<
|
|
35
|
-
|
|
36
|
+
BrandedSchema<'CartPriceReference'> | null | undefined
|
|
36
37
|
> = computed(() => _real?.value?.referencePrice)
|
|
37
38
|
|
|
38
39
|
const displayFrom: ComputedRef<boolean> = computed(() => {
|
|
@@ -50,7 +51,7 @@ export function useProductPrice(
|
|
|
50
51
|
},
|
|
51
52
|
)
|
|
52
53
|
|
|
53
|
-
const _price: ComputedRef<
|
|
54
|
+
const _price: ComputedRef<BrandedSchema<'CalculatedPrice'> | undefined> = computed(
|
|
54
55
|
() => {
|
|
55
56
|
if (displayFrom.value && getProductTierPrices(product.value).length > 1) {
|
|
56
57
|
return product.value?.calculatedPrices?.reduce((previous, current) => {
|
|
@@ -67,7 +68,7 @@ export function useProductPrice(
|
|
|
67
68
|
const totalPrice: ComputedRef<number | undefined> = computed(
|
|
68
69
|
() => _price.value?.totalPrice,
|
|
69
70
|
)
|
|
70
|
-
const price: ComputedRef<
|
|
71
|
+
const price: ComputedRef<BrandedSchema<'CalculatedPrice'> | undefined> = computed(
|
|
71
72
|
() => _price.value,
|
|
72
73
|
)
|
|
73
74
|
|