Skip to content

Commit f607384

Browse files
committed
fix(prepayment-webflow): remove category check
1 parent 3c7d769 commit f607384

File tree

3 files changed

+0
-46
lines changed

3 files changed

+0
-46
lines changed

src/functions/pre-payment-webhook-webflow/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ To set up custom error messages, simply create new variables as described above.
8686

8787
| Variable | Default Value | Description |
8888
| ------------------------------- | ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
89-
| FX_ERROR_CATEGORY_MISMATCH | "Mismatched category." | Occurs if the category of the product does not correspond to the category in Webflow |
9089
| FX_ERROR_INSUFFICIENT_INVENTORY | "Insufficient inventory for these items:" | Occurs when the quantity purchased is greater than the inventory available in Webflow. **A comma separated list of the names of the products out-of-stock will be appended to the end of the error message**. |
9190
| FX_ERROR_PRICE_MISMATCH | "Prices do not match." | Occurs when the price of any of the products does not match with the `price` field in Webflow |
9291

src/functions/pre-payment-webhook-webflow/pre-payment-webhook-webflow.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ function customOptions() {
3131
*/
3232
function getMessages() {
3333
return {
34-
categoryMismatch: process.env['FX_ERROR_CATEGORY_MISMATCH'] || 'Mismatched category.',
3534
insufficientInventory: process.env['FX_ERROR_INSUFFICIENT_INVENTORY'] || 'Insufficient inventory for these items:',
3635
priceMismatch: process.env['FX_ERROR_PRICE_MISMATCH'] || 'Prices do not match.',
3736
}
@@ -274,26 +273,6 @@ function isPriceCorrect(comparable) {
274273
}
275274
}
276275

277-
/**
278-
* Checks if the category of the item is the same as found in WebFlow Collection
279-
*
280-
* @param comparable the enriched item
281-
* @returns {boolean} the categories match
282-
*/
283-
function correctCategory(comparable) {
284-
const wfItem = comparable.wfItem;
285-
const fxItem = comparable.fxItem;
286-
const category = getCustomizableOption(wfItem, 'category');
287-
const categoryExists = !!Object.keys(category).length;
288-
if (!categoryExists) return true;
289-
let matchedCategory;
290-
const embedded = fxItem._embedded;
291-
if (embedded && embedded['fx:item_category']) {
292-
matchedCategory = embedded['fx:item_category'].code;
293-
}
294-
return matchedCategory && category.value.trim() === matchedCategory.trim();
295-
}
296-
297276
/**
298277
* Checks if there is sufficient inventory for this purchase.
299278
*
@@ -469,7 +448,6 @@ function shouldEvaluate(comparable) {
469448
function findMismatch(values) {
470449
const evaluations = [
471450
[isPriceCorrect, getMessages().priceMismatch],
472-
[correctCategory, getMessages().categoryMismatch],
473451
];
474452
for (let v = 0; v < values.length; v += 1) {
475453
if (shouldEvaluate(values[v])) {

src/functions/pre-payment-webhook-webflow/pre-payment-webhook-webflow.test.js

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -359,29 +359,6 @@ describe("Verifies the price of an item in a Webflow collection", () => {
359359
});
360360
});
361361

362-
it("Rejects when any category is incorrect", async () => {
363-
let response;
364-
const event = mockFoxyCart.request();
365-
const items = event.body._embedded["fx:items"];
366-
event.body = JSON.stringify(event.body);
367-
injectedWebflow.items = () =>
368-
Promise.resolve(
369-
mockWebflow.arbitrary(
370-
items,
371-
{ category: () => "WrongCategory" },
372-
)({}, {})
373-
);
374-
const context = {};
375-
await prePayment.handler(event, context, (err, resp) => {
376-
response = resp;
377-
});
378-
expect(response.statusCode).to.deep.equal(200);
379-
expect(JSON.parse(response.body)).to.deep.equal({
380-
ok: false,
381-
details: "Mismatched category.",
382-
});
383-
});
384-
385362
it("Rejects when any inventory is insufficient", async () => {
386363
let response = await insufficientInventoryRequest();
387364
expect(response.statusCode).to.deep.equal(200);

0 commit comments

Comments
 (0)