Nathum Posted October 14, 2015 Share Posted October 14, 2015 Hi, I got sick of having Order Now on products that are sold out. So here is somecode I would like to share, hopefully WHMCS add it. Around Line 75 in \whmcs\templates\orderforms\modern <a href="cart.php?a=add&{if $product.bid}bid={$product.bid}{else}pid={$product.pid}{/if}" class="btn btn-success btn-lg {if $product.qty lt '1'} btn-danger disabled{/if}"><i class="fa fa-shopping-cart"></i> {if $product.qty lt '1'} Sold Out{else}{$LANG.ordernowbutton} {/if}</a> Screenshot 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 23, 2015 Share Posted October 23, 2015 This code is safe for using? I mean if it create any security issue then? looks perfectly safe for me - it's just modifying the button based on stock level. if it were me, i'd prefer it to use a Language entry instead of "Sold Out"... otherwise every user will see "Sold Out" in English regardless of their language choice. <a href="cart.php?a=add&{if $product.bid}bid={$product.bid}{else}pid={$product.pid}{/if}" class="btn btn-success btn-lg {if $product.qty lt '1'} btn-danger disabled{/if}"><i class="fa fa-shopping-cart"></i> {if $product.qty lt '1'} {$LANG.outofstock}{else}{$LANG.ordernowbutton} {/if}</a> then if you need to change "Out of Stock" to "Sold Out" you can use a language override for each language. (Better If someone from mod or developer check this code then it will be very helpful for me, Also I want to display sold out instead of "available 0" "Available 0" doesn't show on my v6 dev - it will show the stock level if it's not zero, but that would be very simple to change it the template. 0 Quote Link to comment Share on other sites More sharing options...
yggdrasil Posted November 22, 2015 Share Posted November 22, 2015 Thank you and as Brian suggested, you should try to use the language variables for text ouput, unless you only use WHMCS in English and are ok with fixed names. 0 Quote Link to comment Share on other sites More sharing options...
Sonu2007 Posted January 21, 2016 Share Posted January 21, 2016 which file / line to edit in case of "Standard Cart" V6 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 21, 2016 Share Posted January 21, 2016 in standard_cart/products.tpl, you could 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... <a href="cart.php?a=add&{if $product.bid}bid={$product.bid}{else}pid={$product.pid}{/if}" class="btn btn-sm {if $product.qty lt '1'}btn-danger disabled{else}btn-success{/if}" id="product{$product@iteration}-order-button"> <i class="fa fa-shopping-cart"></i> {if $product.qty lt '1'} {$LANG.outofstock}{else}{$LANG.ordernowbutton}{/if} </a> that would replace the "Order Now" button with an "Out of Stock" disabled button if the stock level of that product is less than 1. (and assuming you've created the language override for outofstock). 0 Quote Link to comment Share on other sites More sharing options...
Sonu2007 Posted January 21, 2016 Share Posted January 21, 2016 in standard_cart/products.tpl, you could 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... <a href="cart.php?a=add&{if $product.bid}bid={$product.bid}{else}pid={$product.pid}{/if}" class="btn btn-sm {if $product.qty lt '1'}btn-danger disabled{else}btn-success{/if}" id="product{$product@iteration}-order-button"> <i class="fa fa-shopping-cart"></i> {if $product.qty lt '1'} {$LANG.outofstock}{else}{$LANG.ordernowbutton}{/if} </a> that would replace the "Order Now" button with an "Out of Stock" disabled button if the stock level of that product is less than 1. (and assuming you've created the language override for outofstock). it changed all to "Out of Stock" 0 Quote Link to comment Share on other sites More sharing options...
Radsy! Posted January 22, 2016 Share Posted January 22, 2016 Seems to work ok for me a nice little addition to my site.. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 22, 2016 Share Posted January 22, 2016 it changed all to "Out of Stock" that might occur if you have not enabled stock control on the product(s). try using the following code instead, it will now do two checks - first to see whether stock control is enabled on the product, and if so, then check if the qty value is less than 1... if both are true, the item is out of stock and the red disabled button is shown; otherwise the order now button will be displayed. <a href="cart.php?a=add&{if $product.bid}bid={$product.bid}{else}pid={$product.pid}{/if}" class="btn btn-sm {if $product.qty neq '' and $product.qty lt 1}btn-danger disabled{else}btn-success{/if}" id="product{$product@iteration}-order-button"> <i class="fa fa-shopping-cart"></i> {if $product.qty neq '' and $product.qty lt 1}{$LANG.outofstock}{else}{$LANG.ordernowbutton}{/if} </a> 0 Quote Link to comment Share on other sites More sharing options...
Sonu2007 Posted January 22, 2016 Share Posted January 22, 2016 It is showing "order now" for 0 quantity product too 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 22, 2016 Share Posted January 22, 2016 It is showing "order now" for 0 quantity product too not for me - if stock control is enabled and the qty value is 0 (or less), it's showing "Out of Stock"; if you change the value to anything greater than 0, it shows the "Order Now" button - as it does when stock control is disabled. if you're seeing something different, then I might need to see screenshots of the client area output and also the product details settings. 0 Quote Link to comment Share on other sites More sharing options...
Sonu2007 Posted January 22, 2016 Share Posted January 22, 2016 (edited) http://imgur.com/a/Twejc Edited January 22, 2016 by Prahost 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 22, 2016 Share Posted January 22, 2016 how strange... try putting the value back in single quotes again... <a href="cart.php?a=add&{if $product.bid}bid={$product.bid}{else}pid={$product.pid}{/if}" class="btn btn-sm {if $product.qty neq '' and $product.qty lt '1'}btn-danger disabled{else}btn-success{/if}" id="product{$product@iteration}-order-button"> <i class="fa fa-shopping-cart"></i> {if $product.qty neq '' and $product.qty lt '1'}{$LANG.outofstock}{else}{$LANG.ordernowbutton}{/if} </a> 0 Quote Link to comment Share on other sites More sharing options...
Sonu2007 Posted January 22, 2016 Share Posted January 22, 2016 how strange... try putting the value back in single quotes again... <a href="cart.php?a=add&{if $product.bid}bid={$product.bid}{else}pid={$product.pid}{/if}" class="btn btn-sm {if $product.qty neq '' and $product.qty lt '1'}btn-danger disabled{else}btn-success{/if}" id="product{$product@iteration}-order-button"> <i class="fa fa-shopping-cart"></i> {if $product.qty neq '' and $product.qty lt '1'}{$LANG.outofstock}{else}{$LANG.ordernowbutton}{/if} </a> Still same issue 0 Quote Link to comment Share on other sites More sharing options...
Radsy! Posted January 22, 2016 Share Posted January 22, 2016 have you modified any other code in standard_cart/products.tpl, .? + did you make a backup of you original file before editing it 0 Quote Link to comment Share on other sites More sharing options...
Sonu2007 Posted January 22, 2016 Share Posted January 22, 2016 have you modified any other code in standard_cart/products.tpl, .? + did you make a backup of you original file before editing it Not edited anything. Yes i have backup 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 22, 2016 Share Posted January 22, 2016 Still same issue can you add {debug} to the end of the products.tpl template and save, refresh the page in the browser and you should get a popup window. in that window, scroll down to $products and find the entry for PH-NM02 and the qty value - take a screenshot of that part of the popup... or copy&paste the whole popup and PM it to me. btw - have you tried changing lt '1' to eq '0' ? 0 Quote Link to comment Share on other sites More sharing options...
Sonu2007 Posted January 22, 2016 Share Posted January 22, 2016 can you add {debug} to the end of the products.tpl template and save, refresh the page in the browser and you should get a popup window. in that window, scroll down to $products and find the entry for PH-NM02 and the qty value - take a screenshot of that part of the popup... or copy&paste the whole popup and PM it to me. btw - have you tried changing lt '1' to eq '0' ? pm sent. Yes tested with eq '0' still same issue 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 1, 2017 Share Posted February 1, 2017 following a recent PM conversation with another member, I now think the correct code should be... <a href="cart.php?a=add&{if $product.bid}bid={$product.bid}{else}pid={$product.pid}{/if}" class="btn btn-sm {if $product.qty > 0 or !is_numeric($product.qty)}btn-success{else}btn-danger disabled{/if}" id="product{$product@iteration}-order-button"> <i class="fa fa-shopping-cart"></i> {if $product.qty > 0 or !is_numeric($product.qty)}{$LANG.ordernowbutton}{else}{$LANG.outofstock}{/if} </a> 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.