Jump to content
Claudia M

Remove price when out of stock or unavailable

Recommended Posts

On the skin category page I would like to remove the $0.00 price (price info completely) when the item is sold or unavailable (for sale elsewhere ex. eBay) but keep information lined up as is. Thanks for any and all help in this.

 

Capture.PNG.5ad87bb1f2facd302a6e44141453a00f.PNG

Share this post


Link to post
Share on other sites

In the template content.category.php, find the HTML that shows the price. It will look similar to the following:

     <h3>
        {if $product.ctrl_sale}<span class="old_price">{$product.price}</span> <span class="sale_price">{$product.sale_price}</span>
        {else}
        {$product.price}
        {/if}
     </h3>

There is another variable that can be used: the stock level {$product.available}. So, you can wrap the price inside an {if} block:

{if $product.available}
     <h3>
        {if $product.ctrl_sale}<span class="old_price">{$product.price}</span> <span class="sale_price">{$product.sale_price}</span>
        {else}
        {$product.price}
        {/if}
     </h3>
{/if}

Be aware that there may be two or more places that show the price -- a responsive skin. There would be a list view and a grid view, and a maybe a mobile section.

Share this post


Link to post
Share on other sites

I only use the grid view.  Here is my custom code.  Where do I make changes?

Thanks Brian


<div id="ccScroll">
  <ul class="small-block-grid-2 medium-block-grid-3 large-block-grid-3 product_list" data-equalizer>

      {foreach from=$PRODUCTS item=product}
      <li>
         <form action="{$VAL_SELF}" method="post" class="panel add_to_basket">
                 <div class="product_grid_view">
               <div data-equalizer-watch>
                  <div class="text-center"> <a href="{$product.url}" title="{$product.name}"><img class="th" src="{$product.thumbnail}" alt="{$product.name}"></a> </div>
                 <div class="pad-topbottom"><a href="{$product.url}" class="txt black nodecor" title="{$product.name}">{$product.name|truncate:65: "&hellip;"}</a></div>
            </div>
  <div class="med deep-red thinpad-bottom show-for-medium-up">Product Code:&nbsp;{$product.product_code}</div>
                
                {if $product.ctrl_sale}<span class="old_price">{$product.price}</span> <span class="sale_price">{$product.sale_price}</span>
                  {else}
                <div class="pad-bottom txtmed bold">   {$product.price}
                  {/if}
             <a class="right txt black" href="{$product.url}" title="{$product.name}" style="font-weight:normal">More Info</a></div>
                           {if $product.available <= 0}
                <div class="row collapse marg-top">
                  <div class="small-12 columns">
                  <div class="buy_unavailable">See listing for details</div>            
                  </div> </div>
               {* ctrl_stock True when a product is considered 'in stock' for purposes of allowing a purchase, either by actually being in stock or via certain settings *}
               {elseif $product.ctrl_stock && !$CATALOGUE_MODE}
              <div class="row collapse marg-top">
                <div class="small-12 columns ">
                 <button type="submit" value="{$LANG.catalogue.add_to_basket}" class="button br4 expand">{$LANG.catalogue.add_to_basket}</button>
                 <input type="hidden" name="add" value="{$product.product_id}">
                  </div>  </div>
                {elseif !$CATALOGUE_MODE}
               <div class="row collapse marg-top">
                  <div class="small-12 columns">
                    <div class="buy_outofstock">SOLD</div>
                  </div>
               </div>
               {/if}
            </div>
         </form>
      </li>

 

Share this post


Link to post
Share on other sites
Posted (edited)

 

You have this:

   {if $product.ctrl_sale}<span class="old_price">{$product.price}</span> <span class="sale_price">{$product.sale_price}</span>
   {else}
   <div class="pad-bottom txtmed bold">   {$product.price}
   {/if}
   <a class="right txt black" href="{$product.url}" title="{$product.name}" style="font-weight:normal">More Info</a></div>

Change to:

   <div class="pad-bottom txtmed bold">
{if $product.available}
   {if $product.ctrl_sale}<span class="old_price">{$product.price}</span> <span class="sale_price">{$product.sale_price}</span>
   {else}
      {$product.price}
   {/if}
{/if}
   <a class="right txt black" href="{$product.url}" title="{$product.name}" style="font-weight:normal">More Info</a></div>

 

 

Edited by bsmither

Share this post


Link to post
Share on other sites
Posted (edited)

Thank you so much Brian.  This was one of those annoying gnats in your ear things LOL

 

Edited by Claudia M

Share this post


Link to post
Share on other sites

Hey Brian,

That worked if the item is unavailable (ie: listed on eBay etc.) But how do I NOT show the price ( or $0.00) if the item has sold? See the screenshot and my code earlier in this post.

Share this post


Link to post
Share on other sites

We need to know what makes $product.available be true in order to show the price. We also need to know about $product.ctrl_stock.

It could simply be the setting at Add/Edit Product, General tab, "Available for purchase" checkbox.

Are there too many products to go through each and uncheck this setting?

What constitutes being SOLD? Is it Stock Level being zero or less? (As suggested by your code.) Is the setting "Use Stock Level" checked?

So:

{if $product.available and $product.ctrl_stock}

 

Share this post


Link to post
Share on other sites

Hey Brian,

If I use the code you gave me it works like  I want.  Thanks so much!!

{if $product.available and $product.ctrl_stock}

Share this post


Link to post
Share on other sites

To maintain the spacing, change the new code above slightly:

   {else}
      {$product.price}
   {/if}
{/if}

To:

   {else}
      {$product.price}
   {/if}
{else}&nbsp;
{/if}

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...