1

I am trying to display a countdown timer using http://keith-wood.name/countdown.html on my product page to show the remaining time of the catalog rule that applies to that product

I have started with

   $_product = $block->getProduct();

if($_product->getSpecialPrice()){
    echo('<!-- special price -->');
    echo $_product->getSpecialPrice();
    // get special end date
    echo $_product->getSpecialToDate();

}

But it returns nothing, I need the end date to set the timer.

Any tips would be helpful.

1 Answers1

0

this question is a bit broad.

My suggestion would be to look into create a custom widget type, there's a good tutorial here: (http://inchoo.net/magento-2/magento-2-custom-widget/) In that widget you can allow the admin to select which catalog rule to be displayed, along with necessary logic to check if the rule is still active or not.

Then you would add the widget to PDP using custom layout / template rewrite.

William Tran
  • 470
  • 5
  • 11