epicconstruct Posted February 22, 2010 Share Posted February 22, 2010 I wanted to customize the first page of the order process to have a comparison table instead of the row by row list of available products they give you by default. I went to edit the template (/templates/orderforms/web20cart/products.tpl) but I realized the they don't set all of the product variables that I need to be able to give the comparison. Here's the solution I came up with. It's just a block of PHP code that can sit in {php}{/php} smarty tags or an include file at the top of products.tpl. It's purpose is to replace the WHMCS generated variables with a more complete set, while preserving the original variable structure so as to not break the default templates. Once it's in place, you have a whole slew of more variables to call in your template to build your own comparison form. To see what variables are available, put this line in your template: <textarea rows="10" cols="100">{php}print_r($this->_tpl_vars['products']);{/php}</textarea> // Get the product group being displayed $gid = $this->_tpl_vars['gid']; // Query all non-hidden products in current group $query = "SELECT * FROM `tblproducts` WHERE `hidden`='' AND `gid`=$gid ORDER BY `order` ASC"; // Store queried products in $products array $products = array(); $result = mysql_query($query); while ($data = mysql_fetch_array($result,MYSQL_ASSOC)) { $products[] = $data; } // Get the pricing for each product for ($i = 0; $i < count($products); $i++) { $query = "SELECT `msetupfee`, `qsetupfee`, `ssetupfee`, `asetupfee`, `bsetupfee`, `monthly`, `quarterly`, `semiannually`, `annually`, `biennially` FROM `tblpricing` WHERE `type`='product' AND `relid`='" . $products[$i]['id'] . "'"; $result = mysql_query($query); while ($data = mysql_fetch_array($result,MYSQL_ASSOC)) { $products[$i]['pricing']['rawpricing'] = $data; foreach ($products[$i]['pricing']['rawpricing'] as $key => $data) { if ($data != -1.00) $products[$i]['pricing'][$key] = formatCurrency($data); } // Put some other variables in places where WHMCS expects them $products[$i]['pricing']['type'] = $products[$i]['paytype']; $products[$i]['pid'] = $products[$i]['id']; // Make sure quantities work correctly when turned off if ($products[$i]['stockcontrol'] == '') $products[$i]['qty'] = ''; } } // Unset the WHMCS generated smarty tokens $this->clear_assign('products'); // Set new smarty tokens $this->assign('products', $products); I haven't built my new template yet, but I'll share that too when I'm done. You can apply this to the default template and customize it from there. The only thing that should appear differently on the default template is I removed the billing term from the price list. (Ex. $10.00 USD Monthly = $10.00 USD). I did this because the term can still be added to the template directly, and may not be desired in all scenarios. Maybe this will help somebody else. If anybody finds any bugs or has any suggestions let me know and I'll post the fix. 0 Quote Link to comment Share on other sites More sharing options...
epicconstruct Posted February 24, 2010 Author Share Posted February 24, 2010 I've already made some changes to the script above, there were a few things I needed to tweak/fix in it. Since it's still a work in progress I'm not going to keep pasting each version. If anyone is interested send me a PM and I'll share what I have at the time. If there's any interest I'll see about bundling it up into a package. 0 Quote Link to comment Share on other sites More sharing options...
vchosting Posted March 6, 2010 Share Posted March 6, 2010 Any update on the latest version of this epicconstruct 0 Quote Link to comment Share on other sites More sharing options...
epicconstruct Posted March 6, 2010 Author Share Posted March 6, 2010 Any update on the latest version of this epicconstruct Sure, you can see the working copy of it here: http://www.epicconstruct.com/cart.php Right now it's working fine for my purposes, but I haven't fully tested it or packaged it for distribution yet. If you're interested in using it though let me know. 0 Quote Link to comment Share on other sites More sharing options...
vchosting Posted March 6, 2010 Share Posted March 6, 2010 Thanks will take a look and let you know 0 Quote Link to comment Share on other sites More sharing options...
vincent1 Posted March 7, 2010 Share Posted March 7, 2010 Sure, you can see the working copy of it here:http://www.epicconstruct.com/cart.php Right now it's working fine for my purposes, but I haven't fully tested it or packaged it for distribution yet. If you're interested in using it though let me know. That does look good and would be a useful addon. - Vincent 0 Quote Link to comment Share on other sites More sharing options...
epicconstruct Posted March 7, 2010 Author Share Posted March 7, 2010 Awesome, I'm glad you like it. I haven't actually posted an addon to the community addon section before, so let me see what I need to do to get it all together. Do you have any specific requests, or a timeframe you need to have it available by? 0 Quote Link to comment Share on other sites More sharing options...
vincent1 Posted March 7, 2010 Share Posted March 7, 2010 No huge rush, let's say next 2 hours? No seriously, next week or so will be fine. If you can make it so no core files need to be modified I think most of us would appreciate that. Best to have as a single php file to add into our template folder that calls our header/footer? Many thanks for your time on this. - Vincent 0 Quote Link to comment Share on other sites More sharing options...
vchosting Posted March 7, 2010 Share Posted March 7, 2010 Like this well done I would agree with vincents last comment also 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.