Jump to content

How to manage many product using a single product


SametALMDR

Recommended Posts

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 by SametALMDR
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by SametALMDR
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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;
});

 

Link to comment
Share on other sites

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:

  1. 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.
  2. 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.
  3. 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!
  4. 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...

G1ZHp3c.png

<?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...

iB8GFuc.png

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

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