How Can I Associate My Orders With Discounts?
Question
How can I associate my orders with any discounts applied?
Environment
Connector: Shopify
Answer
To associate your orders with any discounts applied, you must use a JOIN
operator to combine the ORDER_LINE
table with the DISCOUNT_APPLICATION
and DISCOUNT_ALLOCATION
tables. You can use the following query:
select
*
from
discount_application
JOIN order_line ol ON discount_application.order_id = order_line.order_id
JOIN discount_allocation dal ON order_line.id = discount_allocation.order_line_id