steam.roy Posted January 5, 2010 Share Posted January 5, 2010 Hello, I would like to know; how would I code a php script that shows how many items in the shopping cart. What API functions I would have to use? I would also like to be able to add other about the cart, such as: Subtotal Total Due Today Empty Cart button Checkout button List of items and prices I would be very thankful for any help on this question. Thanks 0 Quote Link to comment Share on other sites More sharing options...
HerrZ Posted January 5, 2010 Share Posted January 5, 2010 how would I code a php script that shows how many items in the shopping cart. Something fast dirty code like that for smartytemplate: {php} $itemcount = count($this->get_template_vars('products')) + count($this->get_template_vars('domains')) + count($this->get_template_vars('addons')); $this->assign('myitemcount', $itemcount); {/php} <table> <tr><td>Artikel im Warenkorb:</td><td>{$myitemcount}</td></tr> </table> Of Course you can add servers and all the other producttypes. Or recursively run through the $_SESSION['cart'] array and count all the stuff savely. I would also like to be able to add other about the cart, such as:Subtotal Total Due Today Empty Cart button Checkout button List of items and prices which "other"? 0 Quote Link to comment Share on other sites More sharing options...
steam.roy Posted January 5, 2010 Author Share Posted January 5, 2010 which "other"? All of the following: Subtotal Total Due Today Empty Cart button Checkout button List of items and prices I am trying to do a cart status on my site. Thanks for the code, i will try it out. 0 Quote Link to comment Share on other sites More sharing options...
steam.roy Posted January 5, 2010 Author Share Posted January 5, 2010 Also, how does the WHMCS cart work. How does it save what you have chosen? I thought it was a cookie, while the only cookie i can see. when going the cart page is "PHPSESSID". Thanks 0 Quote Link to comment Share on other sites More sharing options...
HerrZ Posted January 5, 2010 Share Posted January 5, 2010 ah, you want to code a minicart. the cart data is stored in $_SESSION['cart']; read out this data in session and complete missing data with mysql querys. the following is a VERY REDUCED idea for coding an whmcs minicart/shoppingbasket for global use: if ($_SESSION['cart']) { // there is someth. in the shoppingcart // mysql productquerys/(and maybe other) to an array if ($_SESSION['cart']['products']) { foreach ($_SESSION['cart']['products'] as $k) { // ... work with $k data and your mysql array ... output } } if ($_SESSION['cart']['domains']) { foreach ($_SESSION['cart']['domains'] as $k) { // ... (maybe here sth.) ...output } } // the other loops for products you want to have in minibasket ... } hope you like/understand 0 Quote Link to comment Share on other sites More sharing options...
steam.roy Posted January 7, 2010 Author Share Posted January 7, 2010 If i was to give you a cart module for joomla's VirtueMart (http://extensions.joomla.org/extensions/129/details). Would you be able to change it whmcs for me? Thanks 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted January 8, 2010 Share Posted January 8, 2010 There is a shopping basket already available. http://www.whmcs.com/members/communityaddons.php?action=viewmod&id=27 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.