Adds dynamic coupon codes and segment plugin
This commit is contained in:
1 parent
ec6a538877
commit
3710f7f80a
41 files changed
+11784
-109
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import randomize from "randomatic"
|
||||
import { BaseService } from "medusa-interfaces"
|
||||
|
||||
class DiscountGeneratorService extends BaseService {
|
||||
constructor({ discountService }) {
|
||||
super()
|
||||
|
||||
this.discountService_ = discountService
|
||||
}
|
||||
|
||||
async generateDiscount(dynamicDiscountCode) {
|
||||
const discount = await this.discountService_.retrieveByCode(dynamicDiscountCode)
|
||||
const data = {
|
||||
code: randomize("A0", 10)
|
||||
}
|
||||
return this.discountService_.createDynamicCode(discount._id, data)
|
||||
}
|
||||
}
|
||||
|
||||
export default DiscountGeneratorService
|
||||
Reference in new issue
Block a user