You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use medusa-plugin-discount-generator.
According to the documentation, the plugin can be tested in two different ways: using the API route /discount-code and using the DiscountGeneratorService.
In the first case i get this error:
TypeError: Cannot read properties of undefined (reading 'object')
at _callee$ (/home/rhaegar/Documenti/Progetti/eCommerceTest/medusa-ecommerce/medusa-ecommerce/node_modules/medusa-plugin-discount-generator/api/index.js:36:51)
at tryCatch (/home/rhaegar/Documenti/Progetti/eCommerceTest/medusa-ecommerce/medusa-ecommerce/node_modules/medusa-plugin-discount-generator/api/index.js:20:2407)
at Generator._invoke (/home/rhaegar/Documenti/Progetti/eCommerceTest/medusa-ecommerce/medusa-ecommerce/node_modules/medusa-plugin-discount-generator/api/index.js:20:1967)
at Generator.next (/home/rhaegar/Documenti/Progetti/eCommerceTest/medusa-ecommerce/medusa-ecommerce/node_modules/medusa-plugin-discount-generator/api/index.js:20:3258)
at asyncGeneratorStep (/home/rhaegar/Documenti/Progetti/eCommerceTest/medusa-ecommerce/medusa-ecommerce/node_modules/medusa-plugin-discount-generator/api/index.js:22:103)
at _next (/home/rhaegar/Documenti/Progetti/eCommerceTest/medusa-ecommerce/medusa-ecommerce/node_modules/medusa-plugin-discount-generator/api/index.js:24:194)
at /home/rhaegar/Documenti/Progetti/eCommerceTest/medusa-ecommerce/medusa-ecommerce/node_modules/medusa-plugin-discount-generator/api/index.js:24:364
at new Promise (<anonymous>)
at /home/rhaegar/Documenti/Progetti/eCommerceTest/medusa-ecommerce/medusa-ecommerce/node_modules/medusa-plugin-discount-generator/api/index.js:24:97
at /home/rhaegar/Documenti/Progetti/eCommerceTest/medusa-ecommerce/medusa-ecommerce/node_modules/medusa-plugin-discount-generator/api/index.js:68:19
::1 - - [16/May/2024:16:02:40 +0000] "POST /discount-code HTTP/1.1" - - "-" "PostmanRuntime/7.36.3"
In the second case, using the given API route example, I get this error:
error: "discountId" must be defined
Error: "discountId" must be defined
at DiscountService.<anonymous> (/home/rhaegar/Documenti/Progetti/eCommerceTest/medusa-ecommerce/medusa-ecommerce/node_modules/@medusajs/medusa/dist/services/discount.js:311:35)
at step (/home/rhaegar/Documenti/Progetti/eCommerceTest/medusa-ecommerce/medusa-ecommerce/node_modules/@medusajs/medusa/dist/services/discount.js:59:23)
at Object.next (/home/rhaegar/Documenti/Progetti/eCommerceTest/medusa-ecommerce/medusa-ecommerce/node_modules/@medusajs/medusa/dist/services/discount.js:40:53)
at /home/rhaegar/Documenti/Progetti/eCommerceTest/medusa-ecommerce/medusa-ecommerce/node_modules/@medusajs/medusa/dist/services/discount.js:34:71
at new Promise (<anonymous>)
at __awaiter (/home/rhaegar/Documenti/Progetti/eCommerceTest/medusa-ecommerce/medusa-ecommerce/node_modules/@medusajs/medusa/dist/services/discount.js:30:12)
at DiscountService.retrieve (/home/rhaegar/Documenti/Progetti/eCommerceTest/medusa-ecommerce/medusa-ecommerce/node_modules/@medusajs/medusa/dist/services/discount.js:305:16)
at DiscountService.<anonymous> (/home/rhaegar/Documenti/Progetti/eCommerceTest/medusa-ecommerce/medusa-ecommerce/node_modules/@medusajs/medusa/dist/services/discount.js:502:67)
at step (/home/rhaegar/Documenti/Progetti/eCommerceTest/medusa-ecommerce/medusa-ecommerce/node_modules/@medusajs/medusa/dist/services/discount.js:59:23)
at Object.next (/home/rhaegar/Documenti/Progetti/eCommerceTest/medusa-ecommerce/medusa-ecommerce/node_modules/@medusajs/medusa/dist/services/discount.js:40:53) {
type: 'not_found',
code: undefined,
date: 2024-05-16T15:58:23.813Z
}
::1 - - [16/May/2024:15:58:23 +0000] "POST /store/generate-discount-code HTTP/1.1" 404 63 "-" "PostmanRuntime/7.36.3"
I do not know how to solve the first case but I understand what's the problem in the second case: in the discount.js file in @medusajs/medusa/dist/services module the generateDiscount function returns this return _context.abrupt("return", this.discountService_.createDynamicCode(discount._id, data));
But the id property in the database is "id" and not "_id" so it doesn't work.
How can this issue be resolved?
Put "id" instead of "_id" in the generateDiscount function inside @medusajs/medusa/dist/services/discount.js file
...
Are you interested in working on this issue?
I would like to fix this issue
The text was updated successfully, but these errors were encountered:
Preliminary Checks
Issue Summary
I'm trying to use medusa-plugin-discount-generator.
According to the documentation, the plugin can be tested in two different ways: using the API route /discount-code and using the DiscountGeneratorService.
In the first case i get this error:
In the second case, using the given API route example, I get this error:
I do not know how to solve the first case but I understand what's the problem in the second case: in the discount.js file in @medusajs/medusa/dist/services module the generateDiscount function returns this
return _context.abrupt("return", this.discountService_.createDynamicCode(discount._id, data));
But the id property in the database is "id" and not "_id" so it doesn't work.
How can this issue be resolved?
...
Are you interested in working on this issue?
The text was updated successfully, but these errors were encountered: