SametALMDR Posted November 19, 2019 Share Posted November 19, 2019 (edited) Dear All, Is there any way to manage many product using a single specific product.I mean there is a single product exits in whmcs.Assume that the product id is 45 and we manage many product using this product ı saw this example in some website which is like cart.php?a=add&pid=67&customfield[77]=1101435 cart.php?a=add&pid=67&customfield[77]=1101496 cart.php?a=add&pid=67&customfield[77]=1121496 I do not understand that how a single product has many prices and text feature areas . Doesn't any problem occur in whmcs ? Can you explain this issue @brian! and dear community members ? Edited November 19, 2019 by SametALMDR 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 20, 2019 Share Posted November 20, 2019 12 hours ago, SametALMDR said: I do not understand that how a single product has many prices and text feature areas . when you say "manage", what do you mean ?? 12 hours ago, SametALMDR said: Assume that the product id is 45 and we manage many product using this product ı saw this example in some website which is like cart.php?a=add&pid=67&customfield[77]=1101435 all these links are doing is passing different values for configurable options for a specific product... https://docs.whmcs.com/Linking_to_WHMCS#Configurable_Options it gives the admin the option of using links to different configurations of the same product, e.g the links may select different server locations for the product to be hosted... 0 Quote Link to comment Share on other sites More sharing options...
SametALMDR Posted November 20, 2019 Author Share Posted November 20, 2019 (edited) Assume that we have a single product and it has a customfield which has an id 77. according to this customfield content like customfield[77]=1101435 , customfield[77]=1101496 ,customfield[77]=1121496 these links has it's own prices how can we do that with a custom field ı attached the example website link down can you check the website please :)::) All of them have different prices and text contents according to customfield value how can ı do that ? Is there any way to do this @brian! https://www.muvhost.com/cart.php?a=add&pid=67&customfield[77]=1101435 https://www.muvhost.com/cart.php?a=add&pid=67&customfield[77]=1121496 https://www.muvhost.com/cart.php?a=add&pid=67&customfield[77]=1097734 Edited November 20, 2019 by SametALMDR 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 20, 2019 Share Posted November 20, 2019 the usual way that would work would be if the customfield had x differently priced options, and then these direct links would be auto selecting a specific configurable option value and that would adjust the price.... out of the box, if this was just a text customfield being passed a value (as per your demo), I don't think it would have any effect on pricing.. possibly if it were a quantity value, but i'd have to see the source site where you saw these links to see what's going on. 0 Quote Link to comment Share on other sites More sharing options...
SametALMDR Posted November 21, 2019 Author Share Posted November 21, 2019 https://www.muvhost.com/almanya-lokasyon-dedicated-sunucular these are the products that ı send to you as a link 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 21, 2019 Share Posted November 21, 2019 so i've been getting confused between customfields and configurable options.... looking at the site, these are just product codes being passed in the custom field.... there must be either template modifications or override hooks in play with this. 0 Quote Link to comment Share on other sites More sharing options...
SametALMDR Posted November 21, 2019 Author Share Posted November 21, 2019 yeah most probably there is an override hooks exist but ı dont understand that how the price does not create any problem in the background 0 Quote Link to comment Share on other sites More sharing options...
SametALMDR Posted November 21, 2019 Author Share Posted November 21, 2019 Thanks a lot @brian!😄 I did an override hook such as below but lastly ı have got a question .How can ı override the description text box according to these code parts ? Can you modifed it 🙂 There is a paramater exist in $vars variables which is named proddata . I guess this array includes such those information about product description . How can ı override the text box information? Can you give an example ? add_hook('OrderProductPricingOverride', 1, function($vars) { $return = []; if ($vars['pid'] == 1) { $return = ['recurring' => '20.00',]; } if ($vars['pid'] == 2) { $return = ['setup'=>'10.00','recurring' => '30.00',]; } if ($vars['pid'] == 3) { $return = ['setup'=>'10.00','recurring' => '30.00',]; } return $return; }); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 22, 2019 Share Posted November 22, 2019 14 hours ago, SametALMDR said: I did an override hook such as below but lastly ı have got a question .How can ı override the description text box according to these code parts ? Can you modified it four things that I should probably mention: this override path is really only a viable solution if you have hundreds of products (as per you linked site) - if you only have a few (even tens), then it's going to take you longer to write the hooks than it would to just enter them into WHMCS as separate products. I know it's just a example hook, but there's no point on changing the pricing based on different PID values - as the whole point of this is that you only want one product. it isn't mentioned in the docs, but with the override hooks, they aren't passing a currency, only an amount - so if your site is multi-currency, then passing a recurring value of '30.00', could be $30, £30, or 30 lei depending on the user's currency... your linked site simplifies this situation by only having one currency and one billing cycle... if you have multiples of either, then this solution would get really complicated really quickly (100+ products * multiple cycles * multiple currencies)... so unless you start checking for currencies and billingcycles, you could end up losing money, e.g your hook above passes a recurring cost of 30.00, but as written that would be applied to all available billing cycles, e.g $30 per month, or 30 lei per 3 years... and that's a huge difference in income! I don't know if that override hook can return proddata - the docs imply it only returns setup & recurring (and that's all i've ever used it for)... clientareapagecart could certainly be used to change the description because all that linked site is doing is returning a specific description value back to the template based on the value of the customfield. 15 hours ago, SametALMDR said: There is a paramater exist in $vars variables which is named proddata . I guess this array includes such those information about product description . it does - but you'll probably have to print it to the screen to really understand its array structure. 15 hours ago, SametALMDR said: How can ı override the text box information? Can you give an example ? so with no hook running... <?php function change_descrption_based_on_product_hook($vars) { if ($vars['templatefile'] == 'configureproduct') { $productinfo = $vars['productinfo']; if ($productinfo['pid'] = 64) { $productinfo['description'] = "It's beginning to look a lot like Christmas."; return array ("productinfo" => $productinfo); } } } add_hook("ClientAreaPageCart", 1, "change_descrption_based_on_product_hook"); with the hook running... now their hook (assuming it's a hook that's changing the description and not a nested Smarty if statement in the configureproduct template) will work based on the value of the customfield rather than the PID value, but you should get the gist of how it works... 0 Quote Link to comment Share on other sites More sharing options...
SametALMDR Posted November 22, 2019 Author Share Posted November 22, 2019 Thanks a lot @brian! 🙂 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.