PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.5
1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk All 48 releases
← All changes | api/Resource/ProductVariationResource.php +28 -20 1.5.0 → 1.6.5 View file →
@@ -64,12 +64,14 @@
64 64 * $data = [
65 65 * 'id' => (int) Required. The variant ID.
66 66 * 'post_id' => (int) Required. The product ID.
67 67 * 'variant_title' => (string) Required. The variant title.
68 - * 'item_price' => (float) Required. The item price.
69 - * 'compare_price' => (float) Required. The compare price.
68 + * 'item_price' => (int) Required. The item price in CENTS — e.g. 129900 means
69 + * $1,299.00. Same unit the API returns on read, and the same
70 + * unit stored. See dev-docs/PRICING-AND-TAX.md §6.
71 + * 'compare_price' => (int) Required. The compare price, in cents (see item_price).
70 72 * 'manage_cost' => (string) Optional. Whether to manage costs.
71 - * 'item_cost' => (float) Required if manage cost is yes. The item cost.
73 + * 'item_cost' => (int) Required if manage cost is yes. The item cost, in cents.
72 74 * 'manage_stock' => (string) Required. Whether to manage stock.
73 75 * 'stock_status' => (string) Required. The stock status.
74 76 * 'stock' => (int) Required. The stock quantity.
75 77 * 'media' => (array) Optional. Info of media files for each variant.
@@ -79,9 +81,9 @@
79 81 * 'other_info' => (array) Optional. Other information for the variant.
80 82 * 'payment_type' => (string) Required. The payment type.
81 83 * 'times' => (string) Required. The number of times.
82 84 * 'repeat_interval' => (string) Required. The repeat interval unit.
83 - * 'signup_fee' => (string) Required. The signup fee.
85 + * 'signup_fee' => (int) Required. The signup fee, in cents (see item_price).
84 86 * 'downloadable_files' => (array) Required if downloadable is true.
85 87 * 'download_limit' => (string) Required. The download limit.
86 88 * 'download_expiry' => (string) Required. The download expiry.
87 89 * 'downloadable' => (bool) Optional. Whether the product is downloadable.
@@ -121,9 +123,10 @@
121 123 unset($otherInfo['signup_fee']);
122 124 unset($otherInfo['setup_fee_per_item']);
123 125 }
124 126 if (Arr::get($otherInfo, 'manage_setup_fee') == 'yes') {
125 - $signupFee = Helper::toCent(floatval(Arr::get($otherInfo, 'signup_fee', 0)));
127 + // Already in cents — normalize only, do not scale.
128 + $signupFee = Helper::roundCent(Arr::get($otherInfo, 'signup_fee', 0));
126 129 Arr::set($otherInfo, 'signup_fee', $signupFee);
127 130 }
128 131 }
129 132
@@ -153,12 +156,14 @@
153 156 'available' => Arr::get($variant, 'available'),
154 157 'committed' => Arr::get($variant, 'committed'),
155 158 'on_hold' => Arr::get($variant, 'on_hold'),
156 159 'stock_status' => $stockStatus,
157 - 'item_price' => Helper::toCent($itemPrice),
158 - //'compare_price' => ($comparePrice !== '' && $comparePrice >= $itemPrice) ? Helper::toCent($comparePrice) : Helper::toCent($itemPrice),
159 - 'compare_price' => ($comparePrice !== '' && $comparePrice >= $itemPrice) ? Helper::toCent($comparePrice) : 0,
160 - 'item_cost' => Helper::toCent(Arr::get($variant, 'item_cost', 0)),
160 + // Amounts arrive already in CENTS. roundCent() only normalizes float
161 + // artifacts (a client-computed 19.99 * 100 arriving as
162 + // 1998.9999999999998) to a whole-cent int — it does not scale.
163 + 'item_price' => Helper::roundCent($itemPrice),
164 + 'compare_price' => ($comparePrice !== '' && $comparePrice >= $itemPrice) ? Helper::roundCent($comparePrice) : 0,
165 + 'item_cost' => Helper::roundCent(Arr::get($variant, 'item_cost', 0)),
161 166 'manage_cost' => Arr::get($variant, 'manage_cost', 'false'),
162 167 'fulfillment_type' => Arr::get($variant, 'fulfillment_type', 'physical'),
163 168 'shipping_class' => Arr::get($variant, 'shipping_class') ?: null,
164 169 'variation_title' => Arr::get($variant, 'variation_title', ''),
@@ -201,12 +206,14 @@
201 206 * $variant = [
202 207 * 'id' => (int) Required. The variant ID.
203 208 * 'post_id' => (int) Required. The product ID.
204 209 * 'variant_title' => (string) Required. The variant title.
205 - * 'item_price' => (float) Required. The item price.
206 - * 'compare_price' => (float) Required. The compare price.
210 + * 'item_price' => (int) Required. The item price in CENTS — e.g. 129900 means
211 + * $1,299.00. Same unit the API returns on read, and the same
212 + * unit stored. See dev-docs/PRICING-AND-TAX.md §6.
213 + * 'compare_price' => (int) Required. The compare price, in cents (see item_price).
207 214 * 'manage_cost' => (string) Optional. Whether to manage costs.
208 - * 'item_cost' => (float) Required if manage cost is yes. The item cost.
215 + * 'item_cost' => (int) Required if manage cost is yes. The item cost, in cents.
209 216 * 'manage_stock' => (string) Required. Whether to manage stock.
210 217 * 'stock_status' => (string) Required. The stock status.
211 218 * 'stock' => (int) Required. The stock quantity.
212 219 * 'media' => (array) Optional. Info of media files for each variant.
@@ -216,9 +223,9 @@
216 223 * 'other_info' => (array) Optional. Other information for the variant.
217 224 * 'payment_type' => (string) Required. The payment type.
218 225 * 'times' => (string) Required. The number of times.
219 226 * 'repeat_interval' => (string) Required. The repeat interval unit.
220 - * 'signup_fee' => (string) Required. The signup fee.
227 + * 'signup_fee' => (int) Required. The signup fee, in cents (see item_price).
221 228 * 'downloadable_files' => (array) Required if downloadable is true.
222 229 * 'download_limit' => (string) Required. The download limit.
223 230 * 'download_expiry' => (string) Required. The download expiry.
224 231 * 'downloadable' => (bool) Optional. Whether the product is downloadable.
@@ -231,10 +238,8 @@
231 238 * 'serial' => (string) Required if files. The file serial
232 239 * 'product_terms' => (array) Optional. Terms of the product.
233 240 * 'product-categories' => (array) Required if categories. Product categories.
234 241 * [0] => (int) Optional. The category ID.
235 - * 'product-tags' => (array) Required if tags. Product tags.
236 - * [0] => (int) Optional. The tag ID.
237 242 * 'product-types' => (array) Required if types. Product types.
238 243 * [0] => (int) Optional. The type ID.
239 244 * ];
240 245 */
@@ -271,9 +276,10 @@
271 276 unset($otherInfo['signup_fee']);
272 277 unset($otherInfo['setup_fee_per_item']);
273 278 }
274 279 if (Arr::get($otherInfo, 'manage_setup_fee') == 'yes') {
275 - $signupFee = Helper::toCent(floatval(Arr::get($otherInfo, 'signup_fee', 0)));
280 + // Already in cents — normalize only, do not scale.
281 + $signupFee = Helper::roundCent(Arr::get($otherInfo, 'signup_fee', 0));
276 282 Arr::set($otherInfo, 'signup_fee', $signupFee);
277 283 }
278 284 }
279 285
@@ -310,12 +316,14 @@
310 316 'committed' => Arr::get($variant, 'committed'),
311 317 'on_hold' => Arr::get($variant, 'on_hold'),
312 318 'shipping_class' => Arr::get($variant, 'shipping_class') ?: null,
313 319 'stock_status' => $stockStatus,
314 - 'item_price' => Helper::toCent($itemPrice),
315 - //'compare_price' => ($comparePrice !== '' && $comparePrice >= $itemPrice) ? Helper::toCent($comparePrice) : Helper::toCent($itemPrice),
316 - 'compare_price' => ($comparePrice !== '' && $comparePrice >= $itemPrice) ? Helper::toCent($comparePrice) : 0,
317 - 'item_cost' => Helper::toCent(Arr::get($variant, 'item_cost', 0)),
320 + // Amounts arrive already in CENTS. roundCent() only normalizes float
321 + // artifacts (a client-computed 19.99 * 100 arriving as
322 + // 1998.9999999999998) to a whole-cent int — it does not scale.
323 + 'item_price' => Helper::roundCent($itemPrice),
324 + 'compare_price' => ($comparePrice !== '' && $comparePrice >= $itemPrice) ? Helper::roundCent($comparePrice) : 0,
325 + 'item_cost' => Helper::roundCent(Arr::get($variant, 'item_cost', 0)),
318 326 'manage_cost' => Arr::get($variant, 'manage_cost', 'false'),
319 327 'fulfillment_type' => Arr::get($variant, 'fulfillment_type', 'physical'),
320 328 'variation_title' => Arr::get($variant, 'variation_title', ''),
321 329 'sku' => Arr::get($variant, 'sku') ?: null,