A plugin which allows you to display a countdown banner on your WooCommerce product pages.
| Contributors | mardellme |
|---|---|
| Tags | woocommerce, dispatch, countdown |
| Requires at least | 4.0 |
| Tested up to | 5.3 |
| Requires PHP | 5.6 |
| Stable tag | 1.0.8 |
| License | GPLv3 or later License |
| URI | http://www.gnu.org/licenses/gpl-3.0.html |
| Plugin URL | https://wordpress.org/plugins/dispatch-countdown/ |
Specify a time to show (and start) the count down, and an end time to count down to.
Ideal for displaying a message such as "For same day dispatch, order within 1h 37m".
You can download the latest release from the WordPress plugin page or from the releases page on GitHub.
- Upload the plugin files to the
/wp-content/plugins/dispatch-countdowndirectory, or install the plugin through the WordPress plugins screen directly. - Activate the plugin through the 'Plugins' screen in WordPress
- Use the WooCommerce->Settings->Product Settings->Dispatch Countdown screen to configure the plugin
The countdown must be called at a point where global $product is available, so
make sure to call this plugin after WooCommerce has loaded. To move the
countdown, you can remove the action and then add it back wherever you want:
/**
* Move dispatch countdown
*/
function your_theme_move_dispatch_countdown() {
// Check the class exists
if ( ! class_exists( 'Dispatch_Countdown' ) ) {
return;
}
// Get the current instance
$dispatch_countdown = Dispatch_Countdown::get_public_instance();
// Remove the action
remove_action( 'woocommerce_before_single_product', array( $dispatch_countdown, 'display_countdown' ) );
// Add the action back where you like
add_action( 'woocommerce_before_main_content', array( $dispatch_countdown, 'display_countdown' ) );
}
add_action( 'init', 'your_theme_move_dispatch_countdown' );Replacing woocommerce_before_main_content with whichever hook you wish
There are a few filters available to override certain parts of the output. The
main filter is dispatch_countdown_content and can be used as follows:
/**
* Change countdown HTML output
*
* NOTE: You must include an element with the id of `dispatch-countdown__time`
* as javascript uses this to update the countdown.
*/
function your_theme_dispatch_countdown_content ( $html, $wording, $product, $countdown ) {
$countdown_html = esc_html( $wording );
$countdown_html .= ' <span id="dispatch-countdown__time" data-for="' . esc_attr( $product ) . '">';
$countdown_html .= esc_html( $countdown );
$countdown_html .= '</span>';
return $countdown_html;
}
add_filter( 'dispatch_countdown_content', 'your_theme_dispatch_countdown_content', 10, 4 );- Removes loader in favour of native WordPress add_filter/add_action
- Expose admin instance for devs
- Use prettier and eslint for JS development
- Update docs
- Add POT file for translations
- Adds filters to main output
- Allow dispatch countdown hook to be overridden
- Update documentation with how to move
- Remove some dist files
- No changes - deployment tests only
- No changes - deployment tests only
- Added icons
- Added screenshots
- Updated readme.txt to adhere to WordPress standards
- Initial release.