-
Notifications
You must be signed in to change notification settings - Fork 35
/
send-a-pdf-invoice-when-an-order-is-created.json
26 lines (26 loc) · 3.46 KB
/
send-a-pdf-invoice-when-an-order-is-created.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{
"docs": "Automatically generate an invoice PDF, to be emailed to the address on file for the order, if the order has not yet been paid. Useful for working with billing departments, or with anyone else who needs an order summary auto-emailed. :)\n\nThis task automatically generates a PDF, based on the supplied HTML template. Configure to taste! To use a template from Order Printer, [see this guide](https://help.usemechanic.com/en/articles/3168408-migrating-templates-from-shopify-to-mechanic).\r\n\r\nNo email will be sent if the order does not have an email on file, or if the order's financial status is not \"pending\".",
"halt_action_run_sequence_on_error": false,
"name": "Send a PDF invoice when an order is created",
"online_store_javascript": null,
"options": {
"days_to_wait_before_emailing__number": null,
"email_subject__required": "Attached: Invoice for order {{ order.name }}",
"email_body__multiline_required": "Hello,\n\nThank you for your order! Please see the attached invoice for details and payment options.\n\nThanks,\n{{ shop.name }}",
"pdf_attachment_filename__required": "invoice-{{ order.order_number }}.pdf",
"pdf_html_template__code_multiline_required": "<h1>Order {{ order.name }} for {{ shop.name }}</h1>\n\n<h2>Items</h2>\n\n<ul>\n {% for line_item in order.line_items %}\n <li>\n {{ line_item.quantity }} x {{ line_item.title }}: {{ line_item.price | money_with_currency }}\n </li>\n {% endfor %}\n</ul>\n\n<h2>Totals</h2>\n\n<ul>\n <li>Items: {{ order.total_line_items_price | money_with_currency }}</li>\n <li>Discounts: {{ order.total_discounts | money_with_currency }}</li>\n <li>Subtotal: {{ order.subtotal_price | money_with_currency }}</li>\n <li>Total (including taxes, shipping, tips): {{ order.total_price | money_with_currency }}</li>\n</ul>\n\n<p>To arrange payment, contact {{ shop.customer_email }}.</p>"
},
"order_status_javascript": null,
"perform_action_runs_in_sequence": false,
"script": "{% comment %}\n Preferred option order:\n\n {{ options.days_to_wait_before_emailing__number }}\n {{ options.email_subject__required }}\n {{ options.email_body__multiline_required }}\n {{ options.pdf_attachment_filename__required }}\n {{ options.pdf_html_template__code_multiline_required }}\n{% endcomment %}\n\n{% if event.preview %}\n {% capture order_json %}\n {\n \"email\": \"[email protected]\",\n \"financial_status\": \"pending\"\n }\n {% endcapture %}\n\n {% assign order = order_json | parse_json %}\n{% endif %}\n\n{% if order.email != blank and order.financial_status == \"pending\" %}\n {% action \"email\" %}\n {\n \"to\": {{ order.email | json }},\n \"subject\": {{ options.email_subject__required | strip | json }},\n \"body\": {{ options.email_body__multiline_required | strip | newline_to_br | json }},\n \"reply_to\": {{ shop.customer_email | json }},\n \"from_display_name\": {{ shop.name | json }},\n \"attachments\": {\n {{ options.pdf_attachment_filename__required | json }}: {\n \"pdf\": {\n \"html\": {{ options.pdf_html_template__code_multiline_required | json }}\n }\n }\n }\n }\n {% endaction %}\n{% endif %}",
"subscriptions": [
"shopify/orders/create"
],
"subscriptions_template": "shopify/orders/create{% if options.days_to_wait_before_emailing__number %}+{{ options.days_to_wait_before_emailing__number }}.days{% endif %}",
"tags": [
"Email",
"Invoice",
"Orders",
"PDF"
]
}