This quick guide shows you how to add a countdown timer to your product page template under the products terms (categories and tags). This guide uses a product ID to target a particular product page so that you don’t have a countdown timer on every page.
/*
* Snippet Name:
* Snippet Author: ecommercehints.com with props to www.w3schools.com for the JS countdown
*/
function action_woocommerce_share() {
global $product;
if ( 15 === $product->get_id() ) { // The product ID to show the countdown timer
echo
'';
}};
// add the action
add_action( 'woocommerce_share', 'action_woocommerce_share', 10, 0 );
2 Responses
Hi
Is there any guide that can explain to me about the way I need to embed the code for it to work for me on a product page?
Thank you!
Hi Itay, you need to add the code snippet to your functions.php file (your host should be able to help you with that). Or, you can add it as a snippet using the Code Snippets plugin (preferable)