This WordPress snippet/plugin tracks WooCommerce product price changes and displays a historical price chart on the single product page using Chart.js.
For Farsi Click Here
- Automatically saves the product's price on each update
- Prevents saving duplicate price values
- Keeps only the latest 30 price records
- Chart display is device-sensitive (mobile, desktop, or all)
- Renders a beautiful animated chart using Chart.js 4
- Responsive chart layout with loading spinner
- Copy the code into your themeโs
functions.php
file or a custom plugin. - Make sure WooCommerce is installed and activated.
- Insert the following shortcode on the product page:
[price_chart]
You can limit where the chart appears:
device value |
Description |
---|---|
all |
Show on all devices |
mobile |
Show only on mobile |
desktop |
Show only on desktop |
- Every time a product is saved, it checks the current price.
- If the price is different from the last stored price, a new entry with timestamp is saved.
- Only the latest 30 price records are kept to avoid data bloat.
- The chart will only be shown if there are at least two entries.
- Type: Line chart
- Library: Chart.js v4.4.4
- Tooltip: Includes both date and formatted price (Vazirmatn font)
- Loader: Animated spinner shown before rendering
- Works only on single product pages
- If there are fewer than two price records, a fallback message is displayed
- You can customize chart fonts, colors, and layout via CSS
- Display price chart in WooCommerce admin panel
- Add export button (CSV/Image)
- Add settings panel for appearance customization
- WordPress 5.0+
- WooCommerce 4.0+
- PHP 7.2+
This project is open-source. You may freely use, edit, and include it in your personal or commercial projects.
Made with โค๏ธ for WooCommerce users.