If the user activates the plugin for the first time (it will be known if we check get_option( 'wc_price_history_settings' )['first_history_scan']
is not set or the value is 0
and in wp_postmeta
the is absence of any single row with meta_key = _wc_price_history
) display admin notice saying it seems to be the first activation and propose the user to scan products to start saving products price's history. The notice should not be able dismiss.
Other options for first_history_scan
:
1
- in progress
2
- done
When use click the button to start the scan, redirect him to a new settings page in menu Woocommerce > Price History > First Run and start scanning products using ajax.
In the batches of ten products, check if they do not have wp_postmeta with meta_key = _wc_price_history
and if not:
- save the current price in the history for the day before the plugin was installed (today)
- save the current price in the history for the day when product has been created
While scanning, display progress bar on this site. When the full scan is done display the info about the end of the process and propose user to be redirected to Woocommerce > Price History to do the plugin setup.
When the scan is started and still in progress (there are still products without wp_postmeta with meta_key = _wc_price_history
), update first_history_save_done to the value of 1. When the scan is done update this settings to the value of 2.
When working with first_history_save_done setting, use PriorPrice\SettingsData
When working with product history, use PriorPrice\HistoryStorage
Checklist