Jump to content

[solved] Hide Basket if no products in Prestashop 1.5.5


Recommended Posts

Hi Community,

 

today i got another question where google isn`t going to help.

 

I need to hide the hole basket in the top right of the shop if there are no products in it.

There are some topics about doin that in Prestashop 1.4.x but all say its different in Prestashop 1.5.x.

 

I think this could be done by an simple "if / else" case but dunno where to search for.

 

Would be great if someone got an idea.

 

Thx a lot.

SM5K

Edited by sm5k (see edit history)
Link to comment
Share on other sites

Hey Vekia

 

user info can stay on place :) But if simpler it can be hidden aswell.

I took a screenshot for you. I want to hide the box marked yellow if no produkts selected,

and first show up if a produkt is added from any page.

 

TY

post-715146-0-65437300-1384962559_thumb.png

Link to comment
Share on other sites

in this case it's necessary to modify blockuserinfo module (not block cart)

in blockuserinfo.tpl file add this code:

{if $cart_qties ==0}

<ul id="header_nav">
{if !$PS_CATALOG_MODE}
<li id="shopping_cart">
<a href="{$link->getPageLink($order_process, true)|escape:'html'}" title="{l s='View my shopping cart' mod='blockuserinfo'}" rel="nofollow">{l s='Cart' mod='blockuserinfo'}
<span class="ajax_cart_quantity{if $cart_qties == 0} hidden{/if}">{$cart_qties}</span>
<span class="ajax_cart_product_txt{if $cart_qties != 1} hidden{/if}">{l s='Product' mod='blockuserinfo'}</span>
<span class="ajax_cart_product_txt_s{if $cart_qties < 2} hidden{/if}">{l s='Products' mod='blockuserinfo'}</span>
<span class="ajax_cart_total{if $cart_qties == 0} hidden{/if}">
{if $cart_qties > 0}
{if $priceDisplay == 1}
{assign var='blockuser_cart_flag' value='Cart::BOTH_WITHOUT_SHIPPING'|constant}
{convertPrice price=$cart->getOrderTotal(false, $blockuser_cart_flag)}
{else}
{assign var='blockuser_cart_flag' value='Cart::BOTH_WITHOUT_SHIPPING'|constant}
{convertPrice price=$cart->getOrderTotal(true, $blockuser_cart_flag)}
{/if}
{/if}
</span>
<span class="ajax_cart_no_product{if $cart_qties > 0} hidden{/if}">{l s='(empty)' mod='blockuserinfo'}</span>
</a>
</li>
{/if}
<li id="your_account"><a href="{$link->getPageLink('my-account', true)|escape:'html'}" title="{l s='View my customer account' mod='blockuserinfo'}" rel="nofollow">{l s='Your Account' mod='blockuserinfo'}</a></li>
</ul>

{/if}

Link to comment
Share on other sites

Hey Vekia and Community,

 

i solved the css as well. Will post the css and tpl parts under this post for people who need.

But now the problem is that the basket stays hidden until you move to another page or do a refresh.

 

Any Ideas how to solve this?

 

Greetz

SM5K

 

_________________________________________________________

blockuserinfo.tpl

____________________________________________

 

<div id="header_user" {if $PS_CATALOG_MODE}class="header_user_catalog"{/if}>
    {if $cart_qties !=0}
    <ul id="header_nav">
        {if !$PS_CATALOG_MODE}
        <li id="shopping_cart">
            <a href="{$link->getPageLink($order_process, true)|escape:'html'}" title="{l s='View my shopping cart' mod='blockuserinfo'}" rel="nofollow">{l s='Cart' mod='blockuserinfo'}
            <span class="ajax_cart_quantity{if $cart_qties == 0} hidden{/if}">{$cart_qties}</span>
            <span class="ajax_cart_product_txt{if $cart_qties != 1} hidden{/if}">{l s='Product' mod='blockuserinfo'}</span>
            <span class="ajax_cart_product_txt_s{if $cart_qties < 2} hidden{/if}">{l s='Products' mod='blockuserinfo'}</span>
            <span class="ajax_cart_total{if $cart_qties == 0} hidden{/if}">
                {if $cart_qties > 0}
                    {if $priceDisplay == 1}
                        {assign var='blockuser_cart_flag' value='Cart::BOTH_WITHOUT_SHIPPING'|constant}
                        {convertPrice price=$cart->getOrderTotal(false, $blockuser_cart_flag)}
                    {else}
                        {assign var='blockuser_cart_flag' value='Cart::BOTH_WITHOUT_SHIPPING'|constant}
                        {convertPrice price=$cart->getOrderTotal(true, $blockuser_cart_flag)}
                    {/if}
                {/if}
            </span>
            <span class="ajax_cart_no_product{if $cart_qties > 0} hidden{/if}">{l s='(empty)' mod='blockuserinfo'}</span>
            </a>
        </li>
        {/if}
        <li id="your_account"><a href="{$link->getPageLink('my-account', true)|escape:'html'}" title="{l s='View my customer account' mod='blockuserinfo'}" rel="nofollow">{l s='Your Account' mod='blockuserinfo'}</a></li>
    </ul>
    {/if}
    {if $cart_qties ==0}
    <div id="headspace"></div>
        {/if}

 

 

_________________________________________________________

blockuserinfo.css

____________________________________________

 

#headspace{height:40px;}

Link to comment
Share on other sites

it will be necessary to do it a bit different.

instead of 

{if $cart_qties !=0}
<ul id="header_nav">
...
...
{/if}

use this:

<ul id="header_nav" {if $cart_qties ==0}style="display:none;"{/if}>

then in ajax-cart.js (blockcart/ajax-cart.js) add code

$("#header_nav").show();

before this:

var $element = $(callerElement).parent().parent().find('a.product_image img,a.product_img_link img');
Link to comment
Share on other sites

×
×
  • Create New...