problem with order/create webhook

alright so my app functionality is based on when an order is created, the entire logic is in the run function of the orders/create action, however, if I add an exception to not run that code on orders/update or orders/risk_assessment_change webhook then it misses the majority of the orders so I cant exempt it from that either. So the problem usually arises with new customers when they update an order that was placed before the app was installed, it runs the same action on that order although that order is old and not actually being created but rather just updated. This is kinda confusing you can help me with it. Another problem which i have talked about previously as well is the missing data in the record object. The workaround I found for this was to just fetch order id drom the record and call the shopify api for the rest but i suspect that has really sky rocketed my request time usage, do you think that might be true?
4 Replies
safwan
safwanOP7mo ago
do you think if i utilize webhook filtering functionality to check if order created at is date.now() or some similiar implementation it would work?
Chocci_Milk
Chocci_Milk7mo ago
Hello, Have you thought about checking the order's shopifyCreatedAt date to see if you should run your logic?
safwan
safwanOP7mo ago
yeah but what do you think would be the best way to implement this, say i use date as today but what if the action gets queued cus its running for 100s of stores for 100s of orders at the same time, what would be a reasonable range to check the order's creation time
Chocci_Milk
Chocci_Milk7mo ago
You can always just check if the date is within a certain range. Lets say, today - 2 weeks? You can use a package like Luxon to manipulate dates more easily or date functions

Did you find this page helpful?