Tags: Demonstration, PDF, Report
This task demonstrates how a product sales report can be generated as PDF and emailed to one or more recipients. It also shows how charts can be embedded in the PDF report using a 3rd party library like ChartJS.
- View in the task library: tasks.mechanic.dev/demonstration-generate-product-sales-report-pdf-with-pie-chart
- Task JSON, for direct import: task.json
- Preview task code: script.liquid
{
"report_on_sales_from_today__boolean": null,
"report_on_sales_from_yesterday__boolean": null,
"report_on_sales_in_past_week__boolean": null,
"report_on_sales_in_past_month__boolean": null,
"report_on_sales_in_past_quarter__boolean": null,
"report_on_sales_in_past_year__boolean": null,
"group_by_product_type__boolean": null,
"group_by_vendor__boolean": null,
"email_report_recipients__array_required": null,
"run_this_task_daily__boolean": null
}
Learn about task options in Mechanic
{% if options.run_this_task_daily__boolean %}
mechanic/scheduler/daily
{% endif %}
mechanic/user/trigger
mechanic/shopify/bulk_operation
Learn about event subscriptions in Mechanic
This task demonstrates how a product sales report can be generated as PDF and emailed to one or more recipients. It also shows how charts can be embedded in the PDF report using a 3rd party library like ChartJS.
By default, the report will generate sales data by product. You may also choose to have the report group sales by product type or vendor. Each group type will generate a single pie chart showing the top 10 products (or types/vendors) by total sales in the selected reporting period.
For the sales reporting period, select only one of the following options:
- Report on sales from today
- Report on sales from yesterday
- Report on sales in the past week
- Report on sales in the past month
- Report on sales in the past quarter
- Report on sales in the past year
The task can be run manually, or optionally, set to run as a daily report by checking the “Run this task daily” option. If a less frequent schedule is desired, then you may modify the mechanic/scheduler/daily subscription to another frequency. See the scheduler section in the docs for more details.
Note: For shops with a high frequency of orders and/or a very large product catalog, these PDF reports can generate a large amount of pages. Consequently, this task should be considered a starting point to develop reporting tasks that work for your shop’s unique requirements.
Find this task in the library at tasks.mechanic.dev, and use the "Try this task" button. Or, import this task's JSON export – see Importing and exporting tasks to learn how imports work.
Found a bug? Got an improvement to add? Start here: ../../CONTRIBUTING.md.
Submit your task requests for consideration by the Mechanic community, and they may be chosen for development and inclusion in the task library!