Magento 2 Private Sales & Flash Sales v4.x Developer Guide and API Reference

The Magento 2 Private Sales & Flash Sales extension allows displaying a countdown timer for any product in your Magento 2 store. Please, follow the instructions below to learn how to perform this.

Display a countdown timer for a product

Changes to be made

Website Frontend – Product Grid

In order to display product countdown timer for products in Magento 2, for example in the product list page – paste the following code into the file template:

app/design/frontend/Infortis/ultimo/Magento_Catalog/templates/product/list.phtml

Code Example

This is an example of the code to be used:

<?php
        if (!(($_cc = $this->helper('MagentoCatalogHelperData')->getCategory())
            &amp;&amp; $_cc->getData('privatesale_date_start'))) {
    ?>
    <?php
        echo $this->getLayout()
            ->createBlock('PlumrocketPrivateSaleBlockEvenProduct')
            ->setTemplate('event/item.phtml')->setProduct($_product)->toHtml()
    ?>
    <?php } ?>

Where “$_product” is a product object the countdown timer you need to set up for. Find the code:

<?php if ($gc['display_name'] != 0): ?>
        <strong class="product name product-item-name product-name<?php echo $productNameClasses; ?>">
            <a class="product-item-link" href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>">
                <?php /* @escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
            </a>
        </strong>
    <?php endif; ?>
    <?php $gc['display_swatches'] = 1; //TODO: add to config ?>

The code should be replaced with the following:

<?php if ($gc['display_name'] != 0): ?>
        <strong class="product name product-item-name product-name<?php echo $productNameClasses; ?>">
            <a class="product-item-link" href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>">
                <?php /* @escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
            </a>
        </strong>
    <?php endif; ?>
    <?php
        if (!(($_cc = $this->helper('MagentoCatalogHelperData')->getCategory())
            &amp;&amp; $_cc->getData('privatesale_date_start'))) {
    ?>
    <?php
        echo $this->getLayout()
            ->createBlock('PlumrocketPrivateSaleBlockEvenProduct')
            ->setTemplate('event/item.phtml')->setProduct($_product)->toHtml()
    ?>
    <?php } ?>
    <?php $gc['display_swatches'] = 1; //TODO: add to config ?>

  1. Product countdown timer.

Was this article helpful?