HyrcanWeb Posted July 1, 2016 Share Posted July 1, 2016 hi i need to show cart items in whmcs homepage (index). ex, show the {$product.name} and price and features and etc... for example, i put this codes in homepage.tpl. but not worked.. <div class="products" id="products"> <div class="row row-eq-height"> {foreach $products as $product} <div class="col-md-6"> <div class="product clearfix" id="product{$product@iteration}"> <header> <span id="product{$product@iteration}-name">{$product.name}</span> {if $product.qty} <span class="qty"> {$product.qty} {$LANG.orderavailable} </span> {/if} </header> <div class="product-desc"> {if $product.featuresdesc} <p id="product{$product@iteration}-description"> {$product.featuresdesc} </p> {/if} <ul> {foreach $product.features as $feature => $value} <li id="product{$product@iteration}-feature{$value@iteration}"> <span class="feature-value">{$value}</span> {$feature} </li> {/foreach} </ul> </div> <footer> <div class="product-pricing" id="product{$product@iteration}-price"> {if $product.bid} {$LANG.bundledeal}<br /> {if $product.displayprice} <span class="price">{$product.displayprice}</span> {/if} {else} {if $product.pricing.hasconfigoptions} {$LANG.startingfrom} <br /> {/if} <span class="price">{$product.pricing.minprice.price}</span> <br /> {if $product.pricing.minprice.cycle eq "monthly"} {$LANG.orderpaymenttermmonthly} {elseif $product.pricing.minprice.cycle eq "quarterly"} {$LANG.orderpaymenttermquarterly} {elseif $product.pricing.minprice.cycle eq "semiannually"} {$LANG.orderpaymenttermsemiannually} {elseif $product.pricing.minprice.cycle eq "annually"} {$LANG.orderpaymenttermannually} {elseif $product.pricing.minprice.cycle eq "biennially"} {$LANG.orderpaymenttermbiennially} {elseif $product.pricing.minprice.cycle eq "triennially"} {$LANG.orderpaymenttermtriennially} {/if} {/if} </div> <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> </footer> </div> </div> {if $product@iteration % 2 == 0} </div> <div class="row row-eq-height"> {/if} {/foreach} </div> </div> 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 1, 2016 Share Posted July 1, 2016 your code would work if the $products array existed on the homepage - but it doesn't... therefore, to make that code work you would need to write an action hook in order to recreate the array. however, if all you want to do is show product name, description, price etc, there is an alternative built-in method - Data Feeds. http://docs.whmcs.com/Data_Feeds you can use them to display the information you want for each product - in WHMCS or outside of it - you just need to identify the product ID (pid) value for each product... e.g to show the product name for pid=1, <script language="javascript" src="feeds/productsinfo.php?pid=1&get=name"></script> if you add a lot of products on your homepage, this method might be slower than using an action hook - but it will work. 0 Quote Link to comment Share on other sites More sharing options...
HyrcanWeb Posted July 1, 2016 Author Share Posted July 1, 2016 your code would work if the $products array existed on the homepage - but it doesn't... therefore, to make that code work you would need to write an action hook in order to recreate the array. how this is ? Data Feeds not a good way for me 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 1, 2016 Share Posted July 1, 2016 how this is ? the $products array is a complicated array and would require a more complex hook than I could post here to recreate it - it would need to query at least two database tables (products & pricing), perhaps more depending on your exact needs (groups, config options etc) - and perform some other output tweaks too. also, in the cart, the $products array only contains the products within that particular group... on the homepage, you might need a very large array if you have many groups and products. Data Feeds not a good way for me that's a shame as it would be the quickest and simplest way to do what you want to do. if you still feel that you need the action hook, you could post in Service Offers & Requests and pay someone to write it for you. 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.