A plugin which allows you to display a countdown banner on your WooCommerce product pages.
Author: | Andy Mardell (profile at wordpress.org) |
WordPress version required: | 4.0 |
WordPress version tested: | 5.3.8 |
Plugin version: | 1.0.7 |
Added to WordPress repository: | 10-12-2019 |
Last updated: | 17-12-2019
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
|
Rating, %: | 100 |
Rated by: | 1 |
Plugin URI: | |
Total downloads: | 657 |
Active installs: | 10+ |
Click to start download
|
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”.
Screenshots
Frontend view
Backend view
FAQ
How do I move the countdown?
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( 'your_theme_before_main_container', array( $dispatch_countdown, 'display_countdown' ) );
}
add_action( 'init', 'your_theme_move_dispatch_countdown' );
Replacing your_theme_before_main_container
with whichever hook you wish
How do I change the HTML output?
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 ) {
// Add the wording
$countdown_html = esc_html( $wording );
// Add the element for js to update – be sure to include the product ID as shown
$countdown_html .= ‘ ‘;
// Add the countdown text
$countdown_html .= esc_html( $countdown );
// Close the countdown element
$countdown_html .= ”;
return $countdown_html;
}
add_filter( ‘dispatch_countdown_content’, ‘your_theme_dispatch_countdown_content’, 10, 4 );`
ChangeLog
1.0.7
- Update docs
- Add POT file for translations
- Adds filters to main output
1.0.6
- Allow dispatch countdown hook to be overridden
- Update documentation with how to move
1.0.5
1.0.4
- No changes – deployment tests only
1.0.3
- No changes – deployment tests only
1.0.2
- Added icons
- Added screenshots
1.0.1
- Updated readme.txt to adhere to WordPress standards
1.0.0