Skip to content

Commit 9cd81d7

Browse files
committed
Enhance Product model to include wholesale price tiers for variations
This commit updates the Product model's getVariations method to incorporate wholesale price tiers for both color variations and attribute variations. The wholesale prices are now sorted by minimum quantity and structured for better accessibility, improving the detail available for each product variation.
1 parent 817750a commit 9cd81d7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

app/Models/Product.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ public function getVariations()
106106
// Cas couleur uniquement
107107
$base["quantity"] = $variation->quantity;
108108
$base["price"] = $variation->price;
109+
// Paliers de prix de gros définis au niveau de la variation couleur
110+
109111
} else {
110112
// Cas couleur + attributs (taille/pointure)
111113
$base["attributes"] = $variation->attributesVariation->map(function($attr) {
@@ -116,8 +118,17 @@ public function getVariations()
116118
"group"=>$attr->attributeValue->attributeValueGroup->label ?? null,
117119
"label"=>$attr->attributeValue->label ?? null,
118120
"quantity" => $attr->quantity ?? null,
119-
120121
"price" => $attr->price ?? null,
122+
// Paliers de prix de gros définis au niveau de l'attribut de variation
123+
"wholesale_prices" => $attr->wholesalePrices
124+
->sortBy("min_quantity")
125+
->values()
126+
->map(function($wp) {
127+
return [
128+
"min_quantity" => $wp->min_quantity,
129+
"wholesale_price" => $wp->wholesale_price,
130+
];
131+
}),
121132
];
122133
});
123134
}

0 commit comments

Comments
 (0)