Jump to content

Conditionally display sections?


tanmalik786

Recommended Posts

Hi there,
I am just about finalizing my first store [for a client] to go live, have come across a challenge, that's "need to setup a 'Best Sellers' section in my store's home page BUT display this label only when there's some Top Seller Products available to display in this section?"

Is this even possible?

Note: I am using 'Creative Elements' as the page builder, if it helps?

TIA

Link to comment
Share on other sites

./modules/ps_bestsellers/views/templates/hook/ps_bestsellers.tpl

original:

<section>
  <h1>{l s='Best Sellers' d='Modules.Bestsellers.Shop'}</h1>
  <div class="products">
    {foreach from=$products item="product"}
      {include file="catalog/_partials/miniatures/product.tpl" product=$product}
    {/foreach}
  </div>
  <a href="{$allBestSellers}">{l s='All best sellers' d='Modules.Bestsellers.Shop'}</a>
</section>

new:

{if $products}
<section>
  <h1>{l s='Best Sellers' d='Modules.Bestsellers.Shop'}</h1>
  <div class="products">
    {foreach from=$products item="product"}
      {include file="catalog/_partials/miniatures/product.tpl" product=$product}
    {/foreach}
  </div>
  <a href="{$allBestSellers}">{l s='All best sellers' d='Modules.Bestsellers.Shop'}</a>
</section>
{/if}

 

./modules/ps_bestsellers/ps_bestsellers.php

original function:

public function getWidgetVariables($hookName, array $configuration)
    {
        $products = $this->getBestSellers();

        if (!empty($products)) {
            return array(
                'products' => $products,
                'allBestSellers' => Context::getContext()->link->getPageLink('best-sales'),
            );
        }

        return false;
    }

new function:

public function getWidgetVariables($hookName, array $configuration)
    {
        $products = $this->getBestSellers();

        if (!empty($products)) {
            return array(
                'products' => $products,
                'allBestSellers' => Context::getContext()->link->getPageLink('best-sales'),
            );
        } else {
            return array(
                'products' => '',
                'allBestSellers' => '',
            );
        }

        return false;
    }

 

Link to comment
Share on other sites

Unfortunately, Creative Elements and various Page Builder modules use custom solutions and custom modules.
As soon as I get such an e-shop, I leave 🙂 because they are confusing.
I'd love to help, but I don't have Creative Elements.

Link to comment
Share on other sites

4 hours ago, Guest said:

Unfortunately, Creative Elements and various Page Builder modules use custom solutions and custom modules.
As soon as I get such an e-shop, I leave 🙂 because they are confusing.
I'd love to help, but I don't have Creative Elements.

Thanks a lot man for your help, I have experience using 'Elementor' for WordPress so thought it will be helpful .. this tool as of now is far from complete [feature wise] I believe.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...