Jump to content

What to hid products out of stock


Netedge

Recommended Posts

8 hours ago, Netedge said:

I am using "modern" template to show products on my WHMCS.

I want to hide products whenever it goes out of stock and show only available products. How can I do that?

in /templates/orderforms/modern/products.tpl, you could add an {if} statement after {foreach from=$products key=num item=product}

{if $product.qty gt 0 or $product.qty eq ""}

and add a closing {if} before the {/foreach}

Link to comment
Share on other sites

9 hours ago, Netedge said:

Its not working for me. Can you please update this file and send it back to me?

if you wanted to just disable the "Order Now" buttons for out of stock products, you could just do this...

<div class="text-right">
	{if $product.qty eq '0' or $product.qty|strstr:'-'}
		<button class="btn btn-danger btn-lg" disabled> {$LANG.outofstock}
	{else}					
		<a href="cart.php?a=add&{if $product.bid}bid={$product.bid}{else}pid={$product.pid}{/if}" class="btn btn-success btn-lg"><i class="fa fa-shopping-cart"></i> {$LANG.ordernowbutton}</a>
	{/if}
</div>

i6M8NcA.png

products.tpl

also, remember that the "Modern" hasn't been updated in years.

https://docs.whmcs.com/Standard_Order_Form_Templates#Depreciated_Order_Form_Templates

Quote

"Boxes" and "Modern" no longer receive updates and may not be compatible with the latest features. They are provided for legacy users only.

if you want to remove product blocks that are out of stock, it's probably going to be easier to write a hook to manipulate the array - otherwise, you'll have blank spaces... although just marking them as out of stock would be easier! :idea:

Link to comment
Share on other sites

if you're going to use standard cart, forget the attached file.

13 minutes ago, Netedge said:

Also I would like to know where should I put the code of out of stock in this file?

change...

                                    <a href="cart.php?a=add&{if $product.bid}bid={$product.bid}{else}pid={$product.pid}{/if}" class="btn btn-success btn-sm" id="product{$product@iteration}-order-button">
                                        <i class="fa fa-shopping-cart"></i>
                                        {$LANG.ordernowbutton}
                                    </a>

to the code in the thread below...

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated