Jump to content

show cart items in homepage


Recommended Posts

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>

Link to comment
Share on other sites

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. :idea:

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

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

  • 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