I want to develop a product discount app for my store. The page has already been implemented, and users can select a collection to include products for the discount when configuring the promotion.
In the product-discount extension, within run.js, I can access the cart data. However, the issue is how should I associate the products with the collection configured in the backend?
I need to check whether the products in the cart are part of this collection. I believe this requires sending a GraphQL query, but how can I do this in run.js?
I’m currently implementing a way to retrieve configuration information from others in run.js, but since run.js is executed on the server side, I cannot fetch the collection data using fetch or axios. The backend logs show an error: “The Wasm module exceeded the instruction count limit.”
Another issue has also arisen: run.js executed on the server side seems unable to obtain the current time using new Date. If I don’t pass in a specific date, the returned time is invalid. For example, using new Date(“2024-08-06”) works correctly, but directly using new Date() doesn’t work.