Overview
The WooCommerce Price History & Sale Compliance plugin ensures your WooCommerce store complies with consumer protection laws like the EU's Omnibus Directive by automatically tracking product price history and displaying the lowest price in the last 30 days on product pages during sales.
π€ Automatic Compliance
Meets EU Omnibus Directive requirements without manual intervention
π Professional Display
Shows compliance information and optional price charts professionally
π Variable Product Support
Properly handles variations with separate price tracking
π° One-time Purchase
No recurring fees or subscriptions
- WordPress 5.8 or higher
- WooCommerce 6.0 or higher
- PHP 7.4 or higher
- MySQL 5.6 or higher
Installation
Method 1: WordPress Admin Upload
- Download the plugin zip file
- Go to Plugins > Add New in your WordPress admin
- Click Upload Plugin
- Choose the zip file and click Install Now
- Click Activate Plugin
Method 2: Manual Installation
- Extract the plugin files to
/wp-content/plugins/wc-price-history-compliance/ - Go to Plugins in WordPress admin
- Find "WooCommerce Price History & Sale Compliance" and click Activate
Configuration
Navigate to WooCommerce > Settings > Price History to configure the plugin.
Compliance Settings
Enable 30-Day Lowest Price Message
Default: Yes
Description: Shows compliance message on product pages during sales
Legal Note: Required for EU Omnibus Directive compliance
Message Text
Default: "Lowest price in the last 30 days: %s"
Usage: Use %s as placeholder for the formatted price
Examples:
- German: "Niedrigster Preis in den letzten 30 Tagen: %s"
- French: "Prix le plus bas dans les 30 derniers jours: %s"
- Spanish: "Precio mΓ‘s bajo en los ΓΊltimos 30 dΓas: %s"
Custom Period (Days)
Default: 30 days
Range: 1-365 days
Legal Note: EU directive requires 30 days minimum
Law/Compliance Tooltip
Default: Empty (disabled)
Example: "Price complies with EU Omnibus Directive 2019/2161 requiring display of lowest price in 30 days prior to discount."
Price Chart Settings
Enable Price History Chart
Default: Yes
Note: Chart only displays when meaningful price history exists (2+ data points)
Features
Automated Price Tracking
The plugin automatically records price changes when:
- Product regular price is updated
- Product sale price is set or modified
- Bulk price updates are performed
- Scheduled sales begin or end
woocommerce_update_product and woocommerce_save_product_variation to ensure all price changes are captured.
Compliance Message Display
When Displayed:
- Only appears during active sales (when sale price < regular price)
- Shows the lowest price recorded in the specified period
- Updates automatically when prices change
Price History Charts
Chart Features
- Interactive line chart using Chart.js
- Responsive design for mobile devices
- Currency formatting matches WooCommerce settings
- Shows 2x the compliance period for better context
Variable Product Handling
- AJAX-powered chart updates when variations are selected
- Each variation maintains separate price history
- Seamless user experience with loading states
Admin Reports
Access via WooCommerce > Price History:
- Complete price change log
- Product search functionality
- Pagination for large datasets
- Export capabilities for compliance audits
Technical Details
Database Schema
The plugin creates a custom table wp_wc_price_history:
CREATE TABLE wp_wc_price_history (
id mediumint(9) NOT NULL AUTO_INCREMENT,
product_id bigint(20) NOT NULL,
price decimal(19,4) NOT NULL,
date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
PRIMARY KEY (id),
KEY product_id (product_id)
);
File Structure
/wc-price-history-compliance/
βββ wc-price-history-compliance.php (Main plugin file)
βββ includes/
β βββ class-price-tracker.php (Price tracking logic)
β βββ class-display-handler.php (Frontend display)
β βββ class-admin-reports.php (Admin interface)
β βββ class-admin-settings.php (Settings page)
β βββ class-install-handler.php (Activation/deactivation)
βββ assets/
β βββ js/
β β βββ chart.js (Frontend chart functionality)
β β βββ admin.js (Admin interface scripts)
β βββ css/
β βββ frontend.css (Frontend styling)
β βββ admin.css (Admin styling)
βββ languages/ (Translation files)
βββ readme.txt (WordPress readme)
WooCommerce Compatibility
- HPOS Compatible: Declares compatibility with High Performance Order Storage
- WooCommerce Blocks: Works with classic and block-based themes
- Multisite: Supports WordPress multisite installations
- Caching: Compatible with popular caching plugins
Performance Considerations
Database Optimization
Optimized with proper indexing and prepared statements
Caching Strategy
Price history data is cached for frontend display
AJAX Loading
Asynchronous loading for variable product charts
Minimal Impact
Price tracking only occurs during product updates
Troubleshooting
Common Issues
Compliance Message Not Showing
- Verify the product is actually on sale (sale price < regular price)
- Check that "Enable 30-Day Lowest Price Message" is enabled in settings
- Ensure there's price history data (product must have been updated since plugin activation)
Price Charts Not Displaying
- Confirm "Enable Price History Chart" is enabled
- Check browser console for JavaScript errors
- Verify Chart.js is loading (check network tab in browser dev tools)
- Ensure the product has at least 2 price history entries
Variable Products Not Working
- Clear any page caching
- Check that variations have separate price history entries
- Verify AJAX requests are succeeding (check browser network tab)
Missing Price History Data
- Price tracking begins after plugin activation
- Historical prices before activation are not automatically imported
- Ensure WooCommerce hooks are not being blocked by other plugins
Debug Mode
Add this to wp-config.php for detailed logging:
define('WCPC_DEBUG', true);
Developer Guide
Hooks and Filters
Filters
wcpc_lowest_price_message_text
Customize the compliance message display:
add_filter('wcpc_lowest_price_message_text', function($message, $product, $lowest_price) {
return '<div class="custom-compliance">' . $message . '</div>';
}, 10, 3);
wcpc_price_history_chart_data
Modify chart data before display:
add_filter('wcpc_price_history_chart_data', function($data, $product_id) {
// Customize chart data
return $data;
}, 10, 2);
wcpc_compliance_period_days
Dynamically adjust the compliance period:
add_filter('wcpc_compliance_period_days', function($days, $product) {
// Return different periods based on product category
return $days;
}, 10, 2);
Actions
wcpc_price_recorded
Triggered when a new price is recorded:
add_action('wcpc_price_recorded', function($product_id, $price, $date) {
// Custom logic when price is recorded
}, 10, 3);
Custom Styling
Override default styles by targeting these CSS classes:
/* Compliance message */
.wcpc-lowest-price-message {
/* Your custom styles */
}
/* Chart container */
.wcpc-chart-container {
/* Your custom styles */
}
/* Law tooltip */
.wcpc-law-tooltip {
/* Your custom styles */
}
Database Access
Access price history data programmatically:
global $wpdb;
$table_name = $wpdb->prefix . 'wc_price_history';
$price_history = $wpdb->get_results($wpdb->prepare(
"SELECT * FROM $table_name WHERE product_id = %d ORDER BY date DESC",
$product_id
));
Legal Compliance
EU Omnibus Directive
This plugin is designed to help comply with the EU Omnibus Directive (2019/2161), specifically Article 6a which requires displaying the lowest price in the 30 days prior to a price reduction.
Key Requirements Met
- Automatic tracking of all price changes
- Display of lowest price during sales
- 30-day minimum tracking period (configurable)
- Accurate calculation including sale prices
- Legal Advice: This plugin provides technical compliance tools but is not legal advice
- Jurisdiction Variations: Different EU countries may have specific implementation requirements
- Regular Updates: Stay informed about changes to consumer protection laws
- Record Keeping: The plugin maintains comprehensive price history for audit purposes
Multi-Country Considerations
| Country | Compliance Message Example |
|---|---|
| Germany | Niedrigster Preis in den letzten 30 Tagen |
| France | Prix le plus bas dans les 30 derniers jours |
| Italy | Prezzo piΓΉ basso negli ultimi 30 giorni |
| Spain | Precio mΓ‘s bajo en los ΓΊltimos 30 dΓas |