Ragonz Posted May 31, 2018 Share Posted May 31, 2018 Is there a way to pull the pricing (Set in Products/Services > Configurable options > option name > configurable option) and display it on a web page? 0 Quote Link to comment Share on other sites More sharing options...
DougK94 Posted May 31, 2018 Share Posted May 31, 2018 You can use a data feed, https://docs.whmcs.com/Data_Feeds 0 Quote Link to comment Share on other sites More sharing options...
Ragonz Posted May 31, 2018 Author Share Posted May 31, 2018 That works if the pricing is set within the product but how would you get it to work if the pricing comes from a configurable option? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 31, 2018 Share Posted May 31, 2018 1 hour ago, Ragonz said: Is there a way to pull the pricing (Set in Products/Services > Configurable options > option name > configurable option) and display it on a web page? on a WHMCS page, pull it from the db in an action hook... outside of WHMCS, as @DougK94 suggests, it would be a data feed... again by querying the db. 0 Quote Link to comment Share on other sites More sharing options...
Ragonz Posted May 31, 2018 Author Share Posted May 31, 2018 (edited) Its a page outside of WHMCS and I've verified that a data feed works but only for products where pricing is set within the product. Most of our products pricing comes from configurable options as the total price is customer selected value x price per slot so for example, if the slot price is £0.50 in a configurable option thats what I need to display on an external page Edited May 31, 2018 by Ragonz 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 31, 2018 Share Posted May 31, 2018 5 hours ago, Ragonz said: Its a page outside of WHMCS and I've verified that a data feed works but only for products where pricing is set within the product. if you're using the productsinfo feed, it's only written for products, you'd have to hack it's code, or rewrite a feed from scratch to get a config option price. as a rough starting point, the data feed below should give you a configurable option price... <?php use WHMCS\Application; use Illuminate\Database\Capsule\Manager as Capsule; require("../init.php"); /* *** USAGE SAMPLES *** <script language="javascript" src="feeds/configprice.php?config=1&billingcycle=monthly¤cy=1"></script> */ $whmcs = Application::getInstance(); $config = $whmcs->get_req_var('config'); $billingCycle = $whmcs->get_req_var('billingcycle'); $currencyID = $whmcs->get_req_var('currency'); $price = Capsule::table('tblpricing')->where('tblpricing.type','configoptions')->where('tblpricing.currency',$currencyID)->where('tblpricing.relid',$config)->value($billingCycle); $price = formatCurrency($price); echo "document.write('".$price."');"; you just need to pass it three variables... configurable option ID. billingcycle. currency. and then pass them like this... <script language="javascript" src="feeds/configprice.php?config=1&billingcycle=monthly¤cy=1"></script> I say it's only rough because i'm not currently doing any validation on the passed fields, e.g checking it's a valid config option and/or currency etc... you can add them in if you need them... 1 Quote Link to comment Share on other sites More sharing options...
Ragonz Posted June 1, 2018 Author Share Posted June 1, 2018 Excellent as always Brian Only question is where to find the config option ID? I go to Setup > Products/Services > Configurable options then select the config option and it tells me the ID is 55 then I click on the configurable option within that "group" for the actual pricing and it tells me its ID is 69 however both 55 and 69 do not give the price set within 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 1, 2018 Share Posted June 1, 2018 9 minutes ago, Ragonz said: Only question is where to find the config option ID? there are a few ways - looking in the db tables; taking the cid value from the popup window when editing the config option... Quote configproductoptions.php?manageoptions=true&cid=16 ... but I suppose one of the simplest would be to view the source in the browser, inspect element on the config option... so let's say we use "7 Ways to Die" and look at the Additional Memory dropdown... so if you wanted the 2GB price, the config id would be 578 and depending on whether you pass "monthly" or "annually" as the billingcycle, it should give you the correct price... I think there may be an issue with sliders, but have a play with the other options and let me know if there is... 0 Quote Link to comment Share on other sites More sharing options...
Ragonz Posted June 1, 2018 Author Share Posted June 1, 2018 Yea its the game slot one I'm after which is a slider, according to that it should be id 69 but that returns a value of £0.70 when its set within the config option to be £0.80 per slot 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 1, 2018 Share Posted June 1, 2018 12 minutes ago, Ragonz said: Yea its the game slot one I'm after which is a slider, according to that it should be id 69 but that returns a value of £0.70 when its set within the config option to be £0.80 per slot ok, leave it with me - I can see the relationship in the tables now... are you happy to pass that it's a slider in the feed URL or would you want the feed to detect whether it's a slider ? 0 Quote Link to comment Share on other sites More sharing options...
Ragonz Posted June 1, 2018 Author Share Posted June 1, 2018 Whatever is the least work for you bud, appreciate all the effort you put in. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 2, 2018 Share Posted June 2, 2018 15 hours ago, Ragonz said: Whatever is the least work for you bud, appreciate all the effort you put in. ok, to keep it simple there are two quick ways to get the config value of a slider - either add {debug} to the template and you can see if it the $configurableoptions array... or in the admin area, setup -> products/services -> configurable options -> *choose config option group* and then in the popup window, Inspect Element on the slider name... ... and in the source, it will show the config option iD value that you can use in the feed... <script language="javascript" src="feeds/configprice.php?config=23&billingcycle=monthly¤cy=1"></script> i've also tweaked the data feed code to give it a quantity option, in case you need to show the price for x number of a particular option. <?php use WHMCS\Application; use Illuminate\Database\Capsule\Manager as Capsule; require("../init.php"); /* *** USAGE SAMPLES *** <script language="javascript" src="feeds/configprice.php?config=1&billingcycle=monthly¤cy=1"></script> */ $whmcs = Application::getInstance(); $config = $whmcs->get_req_var('config'); $billingCycle = $whmcs->get_req_var('billingcycle'); $currencyID = $whmcs->get_req_var('currency'); $qty = $whmcs->get_req_var('qty'); $price = Capsule::table('tblpricing')->where('type','configoptions')->where('currency',$currencyID)->where('relid',$config)->value($billingCycle); if ($qty) {$price = $price * intval($qty);} $price = formatCurrency($price); echo "document.write('".$price."');"; and then to pass it in the feed... <script language="javascript" src="feeds/configprice.php?config=23&billingcycle=monthly¤cy=1&qty=24"></script> 0 Quote Link to comment Share on other sites More sharing options...
Ragonz Posted June 4, 2018 Author Share Posted June 4, 2018 Thats the one. Many thanks. 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.