Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterjaap/6dc68f12a9ce38f6d826ada89747fa3f to your computer and use it in GitHub Desktop.
Save peterjaap/6dc68f12a9ce38f6d826ada89747fa3f to your computer and use it in GitHub Desktop.
These queries fix the order item list in customized order/invoice email templates. Basically you need to change order to order_id and invoice to invoice_id and add area="frontend" if it's not set. Check whether you need to fix it with the SELECT queries, run the UPDATE queries to fix them.
SELECT COUNT(*) FROM email_template WHERE template_text LIKE '%order=%';
SELECT COUNT(*) FROM email_template WHERE template_text LIKE '%invoice=%';
SELECT COUNT(*) FROM email_template WHERE template_text LIKE '%sales_email_order_items%' AND template_text NOT LIKE '%area="frontend"%';
SELECT COUNT(*) FROM email_template WHERE template_text LIKE '%sales_email_order_invoice_items%' AND template_text NOT LIKE '%area="frontend"%';
UPDATE email_template SET template_text = REPLACE(template_text, "order=$order", "order_id=$order_id") WHERE template_text LIKE '%order=%';
UPDATE email_template SET template_text = REPLACE(template_text, "invoice=$invoice", "invoice_id=$invoice_id") WHERE template_text LIKE '%invoice=%';
UPDATE email_template SET template_text = REPLACE(template_text, 'handle="sales_email_order_items"', 'area="frontend" handle="sales_email_order_items"') WHERE template_text LIKE '%sales_email_order_items%' AND template_text NOT LIKE '%area="frontend"%';
UPDATE email_template SET template_text = REPLACE(template_text, 'handle="sales_email_order_invoice_items"', 'area="frontend" handle="sales_email_order_invoice_items"') WHERE template_text LIKE '%sales_email_order_invoice_items%' AND template_text NOT LIKE '%area="frontend"%';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment