On 5/22/2020 at 6:31 PM, BabsD said:I am running crazy. I tried to use the SQL Manager, but it is too complicated for me to use, I don't have the proper knowledge. Is anyone out there who could help me with that? If you live in the U.S. I even can send some Chocolate as a thank you!
Ho can I run an export of this information:
All orders which were using a specific Voucher code including the following informationVoucher Code | Order date | Order status (shipped or delivered) | customer name | order total excl. tax | shipping fees excl tax
I use PS 1.6.1
I think this will work for you... If in order you are having multiple cart rules (voucher) then it will give vouchers as comma separated values
SELECT GROUP_CONCAT(ocr.`name`) AS vouchers, GROUP_CONCAT(cr.`code`) AS voucher_codes, o.`reference` as order_reference, osl.`name` as order_status, o.`current_state`, CONCAT(c.`firstname`, ' ', c.`lastname`) as customer_name, o.`date_add` as order_date, o.`total_paid_tax_excl`, o.`total_shipping_tax_excl` FROM ps_orders o
LEFT JOIN ps_customer as c ON c.id_customer = o.id_customer
LEFT JOIN ps_order_state_lang as osl ON osl.id_order_state = o.current_state AND osl.id_lang = o.id_lang
LEFT JOIN ps_order_cart_rule as ocr ON ocr.id_order = o.id_order
LEFT JOIN ps_cart_rule as cr ON cr.id_cart_rule = ocr.id_cart_rule
GROUP BY o.id_order
And if you want only order with specific voucher code then below will work; replace {CODE_HERE} with your code
SELECT GROUP_CONCAT(ocr.`name`) AS vouchers, GROUP_CONCAT(cr.`code`) AS voucher_codes, o.`reference` as order_reference, osl.`name` as order_status, o.`current_state`, CONCAT(c.`firstname`, ' ', c.`lastname`) as customer_name, o.`date_add` as order_date, o.`total_paid_tax_excl`, o.`total_shipping_tax_excl` FROM ps_orders o LEFT JOIN ps_customer as c ON c.id_customer = o.id_customer LEFT JOIN ps_order_state_lang as osl ON osl.id_order_state = o.current_state AND osl.id_lang = o.id_lang LEFT JOIN ps_order_cart_rule as ocr ON ocr.id_order = o.id_order LEFT JOIN ps_cart_rule as cr ON cr.id_cart_rule = ocr.id_cart_rule WHERE cr.`code` = '{CODE_HERE}' GROUP BY o.id_order
.png.022b5452a8f28f552bc9430097a16da2.png)