Jump to content

Remove price when out of stock or unavailable


Claudia M

Recommended Posts

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.

Link to comment
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>

 

Link to comment
Share on other sites

 

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>

 

 

Link to comment
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}

 

Link to comment
Share on other sites

  • 5 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...