@decocms/apps-commerce 7.42.0 → 7.43.1
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.
- package/package.json +2 -2
- package/src/sdk/useOffer.ts +10 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/apps-commerce",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.43.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Deco commerce apps: shared types, app-registry, and portable commerce utilities",
|
|
6
6
|
"repository": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"lint:unused": "knip"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@decocms/blocks": "7.
|
|
29
|
+
"@decocms/blocks": "7.43.1"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"react": "^19.0.0",
|
package/src/sdk/useOffer.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import type { AggregateOffer, UnitPriceSpecification } from "../types/commerce";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Reducer that selects the "best" installment: lowest total price, tie-broken by
|
|
5
|
+
* highest billingDuration. This is the single source of truth for installment
|
|
6
|
+
* selection — PLP/PDP use it here via `useOffer`, and the VTEX shelf transform
|
|
7
|
+
* (`buildOfferShelf`) reuses it so shelf cards and detail pages never disagree.
|
|
8
|
+
*/
|
|
9
|
+
export const bestInstallment = (
|
|
10
|
+
acc: UnitPriceSpecification | null,
|
|
11
|
+
curr: UnitPriceSpecification,
|
|
12
|
+
) => {
|
|
4
13
|
if (curr.priceComponentType !== "https://schema.org/Installment") {
|
|
5
14
|
return acc;
|
|
6
15
|
}
|