+
Skip to content

Promotions Feature Branch signed #6842

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 230 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
230 commits
Select commit Hold shift + click to select a range
586db86
feat: promotions framework
brent-hoover Sep 13, 2022
d7b391e
fix: fix import noop action
vanpho93 Sep 29, 2022
aff3669
feat: refactor register promotion logic
vanpho93 Sep 29, 2022
aa47cff
feat: save applied promotions to cart
vanpho93 Sep 29, 2022
9bf5335
feat: update promotion api
vanpho93 Oct 4, 2022
b9842a9
feat: add the test for promotions
vanpho93 Oct 5, 2022
bd62dd9
feat: add canBeApplied and enhanceCart functions
vanpho93 Oct 5, 2022
261dd4b
feat: add test case for the canBeApplied function
vanpho93 Oct 5, 2022
1a12a84
fix: fix lint for the canBeApplied function
vanpho93 Oct 5, 2022
1845cad
feat: format and update test description
vanpho93 Oct 12, 2022
f202751
feat: add promotion coupons plugin
vanpho93 Sep 29, 2022
16acf51
feat: add applyExplicitPromotion function for promotion plugin
vanpho93 Oct 7, 2022
219ee7d
feat: apply coupon code to the cart
vanpho93 Oct 10, 2022
9aa7eed
fix: linting
vanpho93 Oct 12, 2022
dbdbc91
fix: change summary and coupon description
vanpho93 Oct 14, 2022
5493dc0
feat: add ability to extend qualifiers
brent-hoover Oct 17, 2022
eae07a6
fix: fix extension
brent-hoover Oct 17, 2022
7e7f974
Update packages/api-plugin-promotions/src/utils/canBeApplied.js
brent-hoover Oct 17, 2022
d436249
fix: typo in schema declaration
brent-hoover Oct 17, 2022
2e5a31e
fix: fix coupon trigger return value
vanpho93 Oct 18, 2022
256e632
feat: add the description for the schema
vanpho93 Oct 19, 2022
7aa8aa8
feat: using anonynous token on promotion coupons
vanpho93 Oct 21, 2022
67cbac7
feat: add indexes
vanpho93 Oct 21, 2022
79b86dd
feat: add first graphQL query for single promotion
brent-hoover Oct 19, 2022
d22ade7
feat: add list query plus updatePromotion
brent-hoover Oct 19, 2022
e229936
feat: working createPromotion
brent-hoover Oct 19, 2022
e4e6927
feat: tests plus validate trigger parameters
brent-hoover Oct 19, 2022
ea4436f
feat: more tests
brent-hoover Oct 20, 2022
3a38020
feat: remove sample-data plugin
brent-hoover Oct 20, 2022
f430789
feat: adds functionality for creating auto-incrementing ids
brent-hoover Nov 10, 2022
d9339d9
feat: refactoring plus adds setting start sequence via env var
brent-hoover Nov 11, 2022
e1b0a3c
feat: add sequence creation in startup, plus graqhQL for promotions
brent-hoover Nov 14, 2022
e2ae3f3
feat: refactoring plus adds setting start sequence via env var
brent-hoover Nov 14, 2022
b6d86bb
feat: adds "promotion type" for stackability and creation purposes
brent-hoover Nov 9, 2022
2e69ab9
feat: modify sample-data inserts
brent-hoover Nov 9, 2022
8bc37fc
fix: feedback from C/R
brent-hoover Nov 9, 2022
2417840
fix: rename from Sequences to sequenceConfigs
brent-hoover Nov 14, 2022
6c46198
fix: rename from Sequences to sequenceConfigs for README
brent-hoover Nov 14, 2022
b091432
fix: fixes for tests
brent-hoover Nov 14, 2022
6ce1b05
fix: change import style to appease Jest
brent-hoover Nov 14, 2022
6b0e27b
fix: typo in index creation declaration
brent-hoover Nov 14, 2022
22766da
fix: correct missing graphQL parameters
brent-hoover Nov 10, 2022
fa5b149
feat: add duplicatePromotion plus name field
brent-hoover Nov 14, 2022
4b9a5d6
fix: fix test
brent-hoover Nov 14, 2022
a29c995
feat: add the promotion-discounts plugin
vanpho93 Oct 20, 2022
0cfb8a7
fix: fix query and mutation tests fail
vanpho93 Nov 1, 2022
7ba94a5
feat: add rules for promotion trigger (uncompleted)
vanpho93 Nov 1, 2022
d7a0e05
feat: inclusion and exclusion for discount item
vanpho93 Nov 2, 2022
1d84343
fix: make getEligibleItems shorter
vanpho93 Nov 3, 2022
b797f49
feat: refactor promotion discount plugin
vanpho93 Nov 4, 2022
dde5845
fix: update pnpm lock
vanpho93 Nov 5, 2022
a374da0
feat: add test for promotion discounts
vanpho93 Nov 5, 2022
acd6d9f
fix: fix integration mutation test fail
vanpho93 Nov 7, 2022
569ee38
fix: calculate percentage discount
vanpho93 Nov 7, 2022
984c950
fix: split order discount for cart items
vanpho93 Nov 8, 2022
b6a025c
fix: fix calculate the order total
vanpho93 Nov 8, 2022
345f117
fix: fix test fail for order plugin
vanpho93 Nov 9, 2022
340c921
feat: update the promotion data on sample-data plugin
vanpho93 Nov 8, 2022
b2f0a33
feat: add integration test for promotions
vanpho93 Nov 14, 2022
388d2e8
fix: fix sample-data records
brent-hoover Nov 15, 2022
cabd89e
fix: fix typo on the tests
vanpho93 Nov 15, 2022
de9ce6e
chore: rename variable
vanpho93 Nov 16, 2022
dcb49ba
feat: add promotion date before/after filter
vannguyenn Nov 16, 2022
8273edc
fix: fix typo and format
vannguyenn Nov 16, 2022
4d7bca1
feat: add discount max units for discount action
vanpho93 Nov 16, 2022
7063578
feat: add discount max value for discount action
vanpho93 Nov 16, 2022
dea1748
feat: add state field and archivePromotion endpoint
brent-hoover Nov 17, 2022
ad80de8
feat: initial work on changing state
brent-hoover Nov 18, 2022
f9ba9aa
feat: watcher that sets state to active/completed when ready
brent-hoover Nov 21, 2022
521eccc
feat: add tests
brent-hoover Nov 21, 2022
2ee5c07
feat: updated lock file
brent-hoover Nov 21, 2022
0a85d0f
feat: add changed package.json
brent-hoover Nov 21, 2022
2992e54
feat: more test fixes
brent-hoover Nov 21, 2022
4fd5944
feat: updates from C/R
brent-hoover Nov 21, 2022
192c7a1
feat: move memory-mongo to the root
brent-hoover Nov 21, 2022
078620a
feat: fix false eslint error
brent-hoover Nov 21, 2022
9cd34f2
feat: increase timeout for tests
brent-hoover Nov 21, 2022
3c8f34c
feat: remove tests for now
brent-hoover Nov 21, 2022
3386c70
feat: remove memory-mongo from root
brent-hoover Nov 21, 2022
e3e1b28
feat: new stack ability
vanpho93 Nov 21, 2022
fa7777a
feat: change stackAbility to stackability
vanpho93 Nov 22, 2022
ecac61b
feat: add per-item stackability for discount plugin
vanpho93 Nov 22, 2022
81143bd
fix: fix for botched rename
brent-hoover Nov 15, 2022
a4f0ee2
fix: fix item discount calculation-methods
vanpho93 Nov 30, 2022
e9179a0
fix: rename inclusionRule adn exclusionRule variables
vanpho93 Dec 5, 2022
ad0fed6
fix: some fixes for promotion update API
vannguyenn Nov 29, 2022
edc7b49
fix: failed test
vannguyenn Dec 5, 2022
8ffece0
fix: update mock fn
vannguyenn Dec 5, 2022
062fbc0
fix: update mock return value
vannguyenn Dec 5, 2022
530dc73
fix: use returnDocument
vannguyenn Dec 5, 2022
5ce1ca8
feat: add archive promotion filter and permissions
vannguyenn Dec 8, 2022
eb1dd3b
fix: add archive promotions to default roles
vannguyenn Dec 9, 2022
162e0ac
fix: add inclusive date filter and fix permission condition
vannguyenn Dec 12, 2022
5c7086e
fix: fix format
vannguyenn Dec 12, 2022
24936ec
fix: revert archive permission
vannguyenn Dec 12, 2022
a359839
fix: fix format and unnecessary changes
vannguyenn Dec 12, 2022
73a7904
fix: remove archive permission
vannguyenn Dec 13, 2022
bc2f58c
fix: remove space
vannguyenn Dec 13, 2022
020a646
feat: add cart messages
vanpho93 Nov 29, 2022
a996af3
feat: add acknowledge cart message mutation
vanpho93 Dec 6, 2022
869c3b8
fix: add cart message condition
vanpho93 Dec 6, 2022
9f4e212
fix: duplicated messages
vanpho93 Dec 6, 2022
dff34df
fix: applyItemDiscountToCart test fail
vanpho93 Dec 6, 2022
f258bc2
fix: applyItemDiscountToCart test fail
vanpho93 Dec 6, 2022
830d800
feat: use findOneAndUpdate instead updateOne for cartMessage
vanpho93 Dec 8, 2022
3830d86
feat: emit afterCartUpdate event when acknowledged cart messasge
vanpho93 Dec 13, 2022
50cedfa
feat: bull queue proof of concept
brent-hoover Nov 23, 2022
22c82d5
feat: experimenting with adding different types of jobs
brent-hoover Nov 24, 2022
b759aad
feat: clean out the api to the bare minimum, remove client plugin
Dec 1, 2022
94588fa
feat: working email sending via bull queue
Dec 6, 2022
8644f8b
feat: add defaults set by env var for adding jobs
Dec 6, 2022
c7061a6
feat: apply some helpful defaults to created queues
brent-hoover Dec 6, 2022
e81b166
feat: convert set promotion state to use bull queue
Dec 7, 2022
dc107fd
feat: add redis to integration test configuration
brent-hoover Dec 7, 2022
922ba8d
feat: don't start queues/jobs if in test mode
Dec 7, 2022
3504fac
feat: don't use promises and only emit event when record is modified
Dec 7, 2022
967f4f6
feat: changes from c/r
Dec 8, 2022
d4ca41a
feat: remove scheduled job when job with same name is added
Dec 8, 2022
f983b35
feat: remove unneeded reference to REACTION_WORKERS_ENABLED
Dec 8, 2022
ad2c218
feat: added missing resolve
Dec 8, 2022
d23904a
chore: changed indentation
Dec 8, 2022
1b49528
chore: fix test by adding nodemailer to deps
Dec 8, 2022
5253e70
chore: put docker-files back
Dec 8, 2022
b2fd08a
chore: point to published version
Dec 8, 2022
c83c64b
chore: update package and readme
brent-hoover Dec 8, 2022
39d3672
fix: don't wrap shutdown in a promise
Dec 13, 2022
7f71ec2
fix: use removeRepeatableByKey
Dec 13, 2022
b1c0d89
fix: supply jobName so queue is properly linked to processor
Dec 13, 2022
ee4d9e7
fix: allow attaching job name to processors
Dec 13, 2022
d000ff9
fix: tweaks from testing
Dec 14, 2022
ead06a1
fix: changes suggested by brian for circleci file
brent-hoover Dec 14, 2022
bca5853
fix: bump dotenv to 7 and add dotenv
Dec 14, 2022
d3ec85f
fix: change import style
Dec 14, 2022
69c9349
fix: add redis env var to jest
brent-hoover Dec 14, 2022
d6f51e4
fix: fix envvar format
Dec 14, 2022
57086f5
fix: eliminate duplicate logging
Dec 14, 2022
e5dfd66
feat: add price type to CartItem
vanpho93 Dec 14, 2022
68314d9
fix: discounts instead of discount
Dec 15, 2022
a1ffca1
fix: discount to discounts
Dec 15, 2022
fde2c65
fix: update promotion with new fields
Dec 13, 2022
65cee0e
feat: add handlers that reprocess carts when promotion state changes
Dec 13, 2022
0418ebf
fix: non-working code
Dec 14, 2022
eab43fa
fix: working cart changed test
Dec 14, 2022
a49b60b
fix: fully working check and update carts in batches
Dec 15, 2022
6799c30
fix: tweaks from re-checking
Dec 15, 2022
93c0d1a
fix: fix projection
Dec 15, 2022
fa348d9
fix: cleaner implementation of cart changed check
Dec 16, 2022
de6443c
feat: preview promotion
vanpho93 Dec 20, 2022
8e7677a
feat: change role review to preview
vanpho93 Dec 26, 2022
57ae914
fix: newly duplicated promotion should have created state
vannguyenn Jan 5, 2023
4a7dafe
revert change of snyk
vannguyenn Jan 6, 2023
273c7e1
fix: add state to update promotion input
vannguyenn Jan 6, 2023
e435dcc
feat: add migration for promotion permissions
vanpho93 Dec 26, 2022
74bde51
feat: add down function for mitation 6
vanpho93 Jan 4, 2023
4fd8da6
feat: promotion-add-integration tests
vanpho93 Dec 22, 2022
d60df52
feat: create promotion mutation on test
vanpho93 Jan 5, 2023
7e44685
fix: change start/end dates to DateTime rather than Date
Jan 13, 2023
8fb58b5
feat: add metafields as fact on get eligibleitems function
vanpho93 Jan 13, 2023
52cf76d
feat: improve promotion validation
vanpho93 Jan 14, 2023
cfa02f3
fix: promotion disabled but still can appliable
vanpho93 Jan 16, 2023
db38342
feat: update first version for new packages
vanpho93 Jan 16, 2023
96908ca
fix: use DateTime rather than Date for tests
Jan 18, 2023
882c4f5
fix: make it a string for GraphQL
brent-hoover Jan 18, 2023
423aec5
fix: use UTC for graphQL tests
Jan 18, 2023
ede448a
fix: use ISO for graphQL tests
Jan 18, 2023
393734b
feat: filter for promotions
sujithvn Jan 1, 2023
3e387cb
fix: add changeset
sujithvn Jan 1, 2023
b6265c0
fix: update promotion shema
vannguyenn Feb 3, 2023
255a96f
fix: update graphql schema
vannguyenn Feb 6, 2023
ff94daf
feat: promotion graphql schema for cart and order
vanpho93 Jan 4, 2023
c2dee9e
feat: enhance duplicate promotion mutation
vanpho93 Feb 8, 2023
9984acb
feat: add additional fields to promotions
vannguyenn Feb 9, 2023
f78a2e1
fix: lock file
vannguyenn Feb 9, 2023
58be488
fix: cart promotion item schema
vannguyenn Feb 14, 2023
048a5cf
feat: add load sequencies sample data
vanpho93 Feb 9, 2023
a931c41
fix: duplicate index key on sequences
vanpho93 Feb 14, 2023
ce66814
fix: use insertedId instead of insertedCount
vannguyenn Feb 21, 2023
a28193f
feat: deprecate discounts plugins
vanpho93 Feb 27, 2023
58c67de
feat: remove discount code integration test
vanpho93 Feb 27, 2023
67384e1
feat: remove discount code query integration test
vanpho93 Feb 27, 2023
3ff70b0
feat: shipping discount method
vanpho93 Feb 16, 2023
2fde9a8
feat: add calculate discount amount util
vanpho93 Feb 20, 2023
5ac4edf
fix: place order with shipping discount
vanpho93 Feb 21, 2023
ff1a1da
fix: calculate shipping discount amount
vanpho93 Feb 21, 2023
d93e5ce
feat: estimate discount amount for shipment quotes
vanpho93 Feb 22, 2023
080b70e
fix: applyPromotion unit test fail
vanpho93 Feb 24, 2023
22a8883
fix: max discount value for shipping discount
vanpho93 Feb 24, 2023
c2aeb8d
feat: add integration test for shipping disocunt
vanpho93 Feb 26, 2023
466473f
fix: unit test fail on disocuntAction
vanpho93 Feb 27, 2023
91615ee
feat: add expect discount amount for integraiton test
vanpho93 Feb 27, 2023
e33484a
feat: two shipping promotion test case
vanpho93 Feb 27, 2023
b1a1758
fix: temporary promotions
vanpho93 Feb 28, 2023
88b7228
feat: create standard coupon mutation
vanpho93 Dec 29, 2022
4e4636e
feat: improve apply coupon mutation
vanpho93 Dec 29, 2022
4bdd98a
feat: remove coupon from cart mutation
vanpho93 Dec 27, 2022
07175ab
feat: update coupon trigger parameter schema
vanpho93 Jan 30, 2023
22ad689
feat: add name field to coupon
vanpho93 Feb 1, 2023
ab8f8a4
feat: add additional coupon validation
vanpho93 Feb 1, 2023
25bcb6f
feat: update promotion error message
vanpho93 Feb 6, 2023
3c51393
fix: add coupon to promotion
vannguyenn Feb 8, 2023
ae86959
feat: add archive coupon mutation
vanpho93 Feb 1, 2023
ea4665b
feat: create migration for old discoupon
vanpho93 Feb 1, 2023
eed6163
fix: add migration down method
vanpho93 Feb 9, 2023
f84f766
fix: migration up error
vanpho93 Feb 10, 2023
13d61f5
fix: should query un-archived coupon in promotion
vannguyenn Feb 16, 2023
a18835a
fix: prevent applied coupon when is archived
vanpho93 Feb 14, 2023
5ffac9a
feat: add additional redeemed coupon information
vanpho93 Feb 27, 2023
7633772
fix: revert snyk
vanpho93 Feb 27, 2023
19299f2
feat: remove usedLogs field on CouponLog schema
vanpho93 Feb 28, 2023
3b10d86
feat: add sample data for shipping promotion
vanpho93 Mar 1, 2023
37f699d
fix: promotion plugin unit test fail
vanpho93 Mar 1, 2023
0db56c7
fix: remove sampleData from plugin file
vanpho93 Mar 1, 2023
b768b1b
fix: checkout promotion test fail
vanpho93 Mar 1, 2023
d943372
feat: add check stackability for the shipping discount
vanpho93 Mar 2, 2023
36dfccd
fix: revert promotion starup file
vanpho93 Mar 2, 2023
4233f57
fix: conflict when rework old commits
vanpho93 May 19, 2023
579dad9
fix: promotion-coupons startup issue
vanpho93 May 22, 2023
c4c69f3
feat: picking best promotions
vanpho93 Mar 2, 2023
0dfebce
Merge pull request #6823 from reactioncommerce/feat/pick-the-best-com…
vanpho93 May 22, 2023
8ec22b2
fix: missing files after signed
vanpho93 May 23, 2023
4b5f393
fix: promotionsVersion and migration check
sujithvn May 24, 2023
000ebdc
Merge branch 'release-5' into feat/promotions-signed
sujithvn May 24, 2023
6a2b0ea
feat: node18 for promotions and test fix
sujithvn May 25, 2023
d2525af
fix: linter fixes
sujithvn May 25, 2023
49bc9a5
Merge branch 'release-5' of github.com:reactioncommerce/reaction into…
sujithvn May 25, 2023
745050d
Merge branch 'release-5' into feat/promotions-signed
sujithvn May 25, 2023
0e6adfe
fix: additional fixes to merge fft promotions
sujithvn May 25, 2023
37d1614
fix: linter error
sujithvn May 25, 2023
773ac27
fix: update the promotionsVersion
sujithvn May 29, 2023
cf8069a
fix: expected total mismatch with shipping discount
vanpho93 Jun 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .changeset/funny-scissors-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@reactioncommerce/api-plugin-promotions": minor
---

filter feature for promotions
7 changes: 7 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ jobs:
command: mongod --oplogSize 128 --replSet rs0 --storageEngine=wiredTiger
ports:
- "27017:27017"
- image: redis
ports:
- "6379:6379"
steps:
- checkout
- restore_cache:
Expand Down Expand Up @@ -132,6 +135,9 @@ jobs:
command: mongod --oplogSize 128 --replSet rs0 --storageEngine=wiredTiger
ports:
- "27017:27017"
- image: redis
ports:
- "6379:6379"
steps:
- checkout
- restore_cache:
Expand Down Expand Up @@ -193,6 +199,7 @@ jobs:
echo "ROOT_URL=http://localhost:3000" >> .env
echo "STORE_URL=http://localhost:4000" >> .env
echo "STRIPE_API_KEY=YOUR_PRIVATE_STRIPE_API_KEY" >> .env
echo "REDIS_SERVER=redis://127.0.0.1:6379" >> .env
- run:
name: Create reaction.localhost network
command: docker network create "reaction.localhost" || true
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,7 @@ yalc-packages

# Build
dist

# Editor
.vscode
.idea
18 changes: 0 additions & 18 deletions .vscode/launch.json

This file was deleted.

2 changes: 2 additions & 0 deletions apps/reaction/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
MONGO_URL=mongodb://mongo.reaction.localhost:27017/reaction
ROOT_URL=http://localhost:3000
STRIPE_API_KEY=YOUR_PRIVATE_STRIPE_API_KEY
REDIS_SERVER=redis://127.0.0.1:6379
MAIL_URL=smtp://localhost:1025
11 changes: 8 additions & 3 deletions apps/reaction/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
"@reactioncommerce/api-plugin-address-validation-test": "1.0.3",
"@reactioncommerce/api-plugin-authentication": "2.2.5",
"@reactioncommerce/api-plugin-authorization-simple": "1.3.2",
"@reactioncommerce/api-plugin-bull-queue": "0.0.0",
"@reactioncommerce/api-plugin-carts": "1.3.5",
"@reactioncommerce/api-plugin-catalogs": "1.1.2",
"@reactioncommerce/api-plugin-discounts": "1.0.4",
"@reactioncommerce/api-plugin-discounts-codes": "1.2.4",
"@reactioncommerce/api-plugin-email": "1.1.5",
"@reactioncommerce/api-plugin-email-smtp": "1.0.8",
"@reactioncommerce/api-plugin-email-templates": "1.1.7",
Expand All @@ -55,6 +54,11 @@
"@reactioncommerce/api-plugin-payments-stripe-sca": "1.0.2",
"@reactioncommerce/api-plugin-pricing-simple": "1.0.7",
"@reactioncommerce/api-plugin-products": "1.3.1",
"@reactioncommerce/api-plugin-promotions": "0.0.0",
"@reactioncommerce/api-plugin-promotions-coupons": "0.0.0",
"@reactioncommerce/api-plugin-promotions-discounts": "0.0.0",
"@reactioncommerce/api-plugin-promotions-offers": ".0.0",
"@reactioncommerce/api-plugin-sequences": "0.0.0",
"@reactioncommerce/api-plugin-settings": "1.0.7",
"@reactioncommerce/api-plugin-shops": "1.3.0",
"@reactioncommerce/api-plugin-simple-schema": "1.0.3",
Expand All @@ -70,9 +74,9 @@
"@reactioncommerce/file-collections": "0.9.3",
"@reactioncommerce/file-collections-sa-gridfs": "0.1.5",
"@reactioncommerce/logger": "1.1.5",
"@reactioncommerce/nodemailer": "5.0.5",
"@reactioncommerce/random": "1.0.2",
"@snyk/protect": "latest",
"nodemailer": "^6.8.0",
"graphql": "~16.6.0",
"semver": "~6.3.0",
"sharp": "^0.30.7"
Expand All @@ -88,6 +92,7 @@
},
"scripts": {
"start": "node --experimental-modules --experimental-json-modules ./src/index.js",
"start:debug": "npm run check-node-version && NODE_ENV=development NODE_OPTIONS='--experimental-modules --experimental-json-modules' nodemon --inspect ./src/index.js",
"start:dev": "npm run check-node-version && NODE_ENV=development NODE_OPTIONS='--experimental-modules --experimental-json-modules' nodemon ./src/index.js",
"inspect": "NODE_ENV=development node --experimental-modules --experimental-json-modules --inspect ./src/index.js",
"inspect-brk": "NODE_ENV=development node --experimental-modules --experimental-json-modules --inspect-brk ./src/index.js",
Expand Down
10 changes: 7 additions & 3 deletions apps/reaction/plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"files": "@reactioncommerce/api-plugin-files",
"shops": "@reactioncommerce/api-plugin-shops",
"settings": "@reactioncommerce/api-plugin-settings",
"sequences": "@reactioncommerce/api-plugin-sequences",
"i18": "@reactioncommerce/api-plugin-i18n",
"email": "@reactioncommerce/api-plugin-email",
"addressValidation": "@reactioncommerce/api-plugin-address-validation",
Expand All @@ -25,8 +26,6 @@
"payments": "@reactioncommerce/api-plugin-payments",
"paymentsStripeSCA": "@reactioncommerce/api-plugin-payments-stripe-sca",
"paymentsExample": "@reactioncommerce/api-plugin-payments-example",
"discounts": "@reactioncommerce/api-plugin-discounts",
"discountCodes": "@reactioncommerce/api-plugin-discounts-codes",
"surcharges": "@reactioncommerce/api-plugin-surcharges",
"fulfillment": "@reactioncommerce/api-plugin-fulfillment",
"fulfillmentTypeShipping": "@reactioncommerce/api-plugin-fulfillment-type-shipping",
Expand All @@ -39,5 +38,10 @@
"navigation": "@reactioncommerce/api-plugin-navigation",
"sitemapGenerator": "@reactioncommerce/api-plugin-sitemap-generator",
"notifications": "@reactioncommerce/api-plugin-notifications",
"addressValidationTest": "@reactioncommerce/api-plugin-address-validation-test"
"addressValidationTest": "@reactioncommerce/api-plugin-address-validation-test",
"promotions": "@reactioncommerce/api-plugin-promotions",
"promotionsCoupons": "@reactioncommerce/api-plugin-promotions-coupons",
"promotionsDiscounts": "@reactioncommerce/api-plugin-promotions-discounts",
"promotionsOffers": "@reactioncommerce/api-plugin-promotions-offers",
"bullJobQueue": "@reactioncommerce/api-plugin-bull-queue"
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ beforeAll(async () => {
catalogItem = Factory.Catalog.makeOne({
isDeleted: false,
product: Factory.CatalogProduct.makeOne({
title: "Test Product",
isDeleted: false,
isVisible: true,
variants: Factory.CatalogProductVariant.makeMany(1, {
Expand Down Expand Up @@ -79,7 +80,8 @@ beforeAll(async () => {
anonymousAccessToken: hashToken(cartToken),
shipping: null,
items: [],
workflow: null
workflow: null,
discounts: []
});
opaqueCartId = encodeOpaqueId("reaction/cart", mockCart._id);
await testApp.collections.Cart.insertOne(mockCart);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mutation CreatePromotion($input: PromotionCreateInput!) {
createPromotion(input: $input) {
success
promotion {
_id
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const SelectFulfillmentOptionForGroupMutation = importAsString("./SelectFulfillm
const SetShippingAddressOnCartMutation = importAsString("./SetShippingAddressOnCartMutation.graphql");
const UpdateCartItemsQuantityMutation = importAsString("./UpdateCartItemsQuantityMutation.graphql");
const UpdateFulfillmentOptionsForGroupMutation = importAsString("./UpdateFulfillmentOptionsForGroupMutation.graphql");
const CreatePromotionMutation = importAsString("./CreatePromotionMutation.graphql");

jest.setTimeout(300000);

Expand All @@ -25,6 +26,10 @@ const opaqueProductId = encodeProductOpaqueId(999);
const internalTagIds = ["923", "924"];
const internalVariantIds = ["875", "874", "925"];

const internalProductTwoId = "888";
const opaqueProductTwoId = encodeProductOpaqueId(888);
const internalVariantTwoIds = ["889", "890"];

const shopName = "Test Shop";

const mockProduct = {
Expand Down Expand Up @@ -65,6 +70,35 @@ const mockOptionTwo = {
price: 29.99
};

const mockProductTwo = {
_id: internalProductTwoId,
ancestors: [],
title: "Fake Product two",
isDeleted: false,
isVisible: true,
supportedFulfillmentTypes: ["shipping"],
vendor: "Nike"
};

const mockVariantTwo = {
_id: internalVariantTwoIds[0],
ancestors: [internalProductTwoId],
attributeLabel: "Variant",
title: "Fake Product Two Variant",
isDeleted: false,
isVisible: true
};

const mockOptionTwoOne = {
_id: internalVariantTwoIds[1],
ancestors: [internalProductTwoId, internalVariantTwoIds[0]],
attributeLabel: "Option",
title: "Fake Product Two Option One",
isDeleted: false,
isVisible: true,
price: 19.99
};

const mockShippingMethod = {
_id: "mockShippingMethod",
name: "Default Shipping Provider",
Expand Down Expand Up @@ -96,6 +130,7 @@ let addCartItems;
let availablePaymentMethods;
let createCart;
let createShop;
let createPromotion;
let internalShopId;
let opaqueShopId;
let placeOrder;
Expand Down Expand Up @@ -129,6 +164,7 @@ beforeAll(async () => {
setShippingAddressOnCart = testApp.mutate(SetShippingAddressOnCartMutation);
updateCartItemsQuantity = testApp.mutate(UpdateCartItemsQuantityMutation);
updateFulfillmentOptionsForGroup = testApp.mutate(UpdateFulfillmentOptionsForGroupMutation);
createPromotion = testApp.mutate(CreatePromotionMutation);

const shopCreateGroup = Factory.Group.makeOne({
_id: "shopCreateGroup",
Expand All @@ -151,29 +187,27 @@ beforeAll(async () => {

const {
createShop: {
shop: {
_id: newShopId
}
shop: { _id: newShopId }
}
} = await createShop({
input: {
name: shopName
}
});

opaqueShopId = newShopId;
internalShopId = decodeOpaqueIdForNamespace("reaction/shop", newShopId);

const adminGroup = Factory.Group.makeOne({
_id: "adminGroup",
createdBy: null,
name: "admin",
permissions: ["reaction:legacy:products/publish"],
permissions: ["reaction:legacy:products/publish", "reaction:legacy:promotions/create"],
slug: "admin",
shopId: newShopId
shopId: internalShopId
});
await testApp.collections.Groups.insertOne(adminGroup);

opaqueShopId = newShopId;
internalShopId = decodeOpaqueIdForNamespace("reaction/shop", newShopId);

// Set other shop settings
await testApp.collections.Shops.updateOne(
{ _id: internalShopId },
Expand All @@ -195,14 +229,20 @@ beforeAll(async () => {
mockVariant.shopId = internalShopId;
mockOptionOne.shopId = internalShopId;
mockOptionTwo.shopId = internalShopId;
mockProductTwo.shopId = internalShopId;
mockVariantTwo.shopId = internalShopId;
mockOptionTwoOne.shopId = internalShopId;
await Promise.all(internalTagIds.map((_id) => testApp.collections.Tags.insertOne({ _id, shopId: internalShopId, slug: `slug${_id}` })));
await testApp.collections.Products.insertOne(mockProduct);
await testApp.collections.Products.insertOne(mockVariant);
await testApp.collections.Products.insertOne(mockOptionOne);
await testApp.collections.Products.insertOne(mockOptionTwo);
await testApp.collections.Products.insertOne(mockProductTwo);
await testApp.collections.Products.insertOne(mockVariantTwo);
await testApp.collections.Products.insertOne(mockOptionTwoOne);

// Publish products to the catalog
await publishProducts({ productIds: [opaqueProductId] });
await publishProducts({ productIds: [opaqueProductId, opaqueProductTwoId] });
});

// eslint-disable-next-line require-jsdoc
Expand All @@ -212,10 +252,13 @@ export default function getCommonData() {
availablePaymentMethods,
createCart,
createShop,
createPromotion,
encodeProductOpaqueId,
internalShopId,
internalVariantIds,
internalVariantTwoIds,
opaqueProductId,
opaqueProductTwoId,
opaqueShopId,
placeOrder,
publishProducts,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
export const fixedDiscountPromotion = {
name: "$10 off when you spend more than $100",
label: "Order promotion",
description: "$10 off when you spend more than $100",
actions: [
{
actionKey: "discounts",
actionParameters: {
discountType: "order",
discountCalculationType: "fixed",
discountValue: 10
}
}
],
triggers: [
{
triggerKey: "offers",
triggerParameters: {
name: "$10 off when you spend more than $100",
conditions: {
all: [
{
fact: "totalItemAmount",
operator: "greaterThanInclusive",
value: 100
}
]
}
}
}
],
promotionType: "order-discount",
enabled: true,
stackability: {
key: "all",
parameters: {}
}
};

export const percentagePromotion = {
name: "%10 off when you spend more than $100",
description: "%10 off when you spend more than $100",
actions: [
{
actionKey: "discounts",
actionParameters: {
discountType: "order",
discountCalculationType: "percentage",
discountValue: 10
}
}
],
triggers: [
{
triggerKey: "offers",
triggerParameters: {
name: "%10 off when you spend more than $100",
conditions: {
all: [
{
fact: "totalItemAmount",
operator: "greaterThanInclusive",
value: 100
}
]
}
}
}
],
triggerType: "implicit",
promotionType: "order-discount",
enabled: true,
stackability: {
key: "all",
parameters: {}
}
};
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载