Skip to content

Instantly share code, notes, and snippets.

@elisei
Forked from tegansnyder/abandon-cart.sql
Created January 20, 2017 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elisei/36bfd41c0e6c1f6ec0abceda554bd7d8 to your computer and use it in GitHub Desktop.
Save elisei/36bfd41c0e6c1f6ec0abceda554bd7d8 to your computer and use it in GitHub Desktop.
Abandon Cart example
SELECT `main_table`.*,
(main_table.base_subtotal_with_discount*main_table.base_to_global_rate) AS `subtotal`,
`cust_email`.`email`,
`cust_fname`.`value` AS `firstname`,
`cust_lname`.`value` AS `lastname`,
CONCAT_WS(' ', cust_fname.value, cust_lname.value) AS `customer_name`
FROM `sales_flat_quote` AS `main_table`
INNER JOIN `customer_entity` AS `cust_email` ON cust_email.entity_id = main_table.customer_id
INNER JOIN `customer_entity_varchar` AS `cust_fname` ON cust_fname.entity_id = main_table.customer_id
AND cust_fname.attribute_id = 5
INNER JOIN `customer_entity_varchar` AS `cust_lname` ON cust_lname.entity_id = main_table.customer_id
AND cust_lname.attribute_id = 7
WHERE (items_count != '0')
AND (main_table.is_active = '1')
ORDER BY updated_at DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment