-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix(core-flows): update cart promotion data usage #9456
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
6 Skipped Deployments
|
|
@shahednasser did we documented that? The fact that when you want to use data in workflows you are not really manipulating them but rather manipulating proxies under the hood, so nullishcoalescing and ternary like that can't work. Instead users should rely on transformers |
No not aware of this. I can document it tomorrow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect we might be doing this more places, I recently found a similar pattern in a cart workflow
Humm, but I was sure we share that internally and the same about data manipulation in general in workflow. It is just a composer basically to organize steps and stuff in the order they should be executed and we allow through utils to have places to manipulate the data to be ingested by steps and sub workflows |
Basically the composer function only serves to compose a flow with a certain order of execution and configuration. Then we have utils like transform which allow to manipulate data if needed and then those are resolved when we reach a strp or workflow consuming it. Cc @carlos-r-l-rodrigues we might write again about it wdyt? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this might be a long stretch, but can we detect if we're doing this within the proxies and throw an error?
In hindsight, I knew this wasn't correct, but because I'm writing in "JS", it was just intuitive to continue along. 😅
🤣 unfortunately there is no way for us to know unless we do a static analysis of the composer function. The proxies are around the object so that when you access a prop it generates a transformer for you instead. |
const promotionCodesToApply = getPromotionCodesToApply({ | ||
cart: cart, | ||
promo_codes: input.promo_codes ?? [], | ||
action: input.action || PromotionActions.ADD, | ||
promo_codes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on another note, this could probably also be handled by the step itself, so that it is more resuable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes 100% but it is also handled I believe
**What** The nullish coalescing can't really work since we are using proxies under the hood which is present
What
The nullish coalescing can't really work since we are using proxies under the hood which is present