Jump to content

Configurable options display only annually price


JelleG

Recommended Posts

Hi,

 

I created a new configurable option with radio buttons.

By default the entire name of the option is displayed inside the cart, with the name + price.

It is loaded by this phrase "{$options.name}".

 

I already found the way to display the name of the configurable option only.

That is "{$configoption.options.0.nameonly}".

 

Does anyone know the phrase to load the annually price of the configurable option?

Link to comment
Share on other sites

I already found the way to display the name of the configurable option only.

That is "{$configoption.options.0.nameonly}".

technically, you should probably be using {$options.nameonly} - the above would only work if it's the first of your config options.

 

Does anyone know the phrase to load the annually price of the configurable option?

the config option array only contains the price for the current billing cycle - so if the billing cycle is set to Annually, then the config option Annually price will be shown... if the cycle is changed to one where the config option isn't priced, then it will be free.

Link to comment
Share on other sites

technically, you should probably be using {$options.nameonly} - the above would only work if it's the first of your config options.

 

 

the config option array only contains the price for the current billing cycle - so if the billing cycle is set to Annually, then the config option Annually price will be shown... if the cycle is changed to one where the config option isn't priced, then it will be free.

 

Thanks a lot!!

 

{$options.nameonly} works perfect.

 

How can I load the price only? Because I tried {$options.priceonly} but that does not work.

Is there a way to load only the price of the current biling cycle?

Link to comment
Share on other sites

How can I load the price only? Because I tried {$options.priceonly} but that does not work.

Is there a way to load only the price of the current biling cycle?

well, {$options.priceonly} doesn't exist - in fact, there isn't really an existing variable that gives you the price, with currency, by itself - you'll have to work with what you have access to!

 

two options - either should work...

 

{$currency.prefix}{$options.fullprice}{$currency.suffix}

or..

 

{$options.name|replace:$options.nameonly:''}

Link to comment
Share on other sites

well, {$options.priceonly} doesn't exist - in fact, there isn't really an existing variable that gives you the price, with currency, by itself - you'll have to work with what you have access to!

 

two options - either should work...

 

{$currency.prefix}{$options.fullprice}{$currency.suffix}

or..

 

{$options.name|replace:$options.nameonly:''}

 

 

You really made my day. Works perfect. Thanks a lot

Link to comment
Share on other sites

well, {$options.priceonly} doesn't exist - in fact, there isn't really an existing variable that gives you the price, with currency, by itself - you'll have to work with what you have access to!

 

two options - either should work...

 

{$currency.prefix}{$options.fullprice}{$currency.suffix}

or..

 

{$options.name|replace:$options.nameonly:''}

 

Hopefully you can also help me with adding it correctly to the cart summery.

Inside the cart summery everything is loaded with:

{$configoption.name}

and

{$configoption.option}

 

How can I load the following data inside the cart?

 

- Name only

- Price only

- Option ID

Link to comment
Share on other sites

Name only -> {$configoption.optionname}

Recurring Price only -> {$configoption.recurring}

Setup Price only -> {$configoption.setup}

 

the configurable option ID isn't passed to the order summary template.

 

Great thanks a lot!

 

Last question I have is, some options do have price 0,00.

 

How can I replace the price of 0,00 to a text "Free"?

 

Can I use something like this:

 

 {if $configoption.recurring== 'someguy'} {else} {/if} 

Link to comment
Share on other sites

if you wanted to make it multilingual, i'd be more tempted to use...

 

{if $configoption.recurring eq '0,00€'}{$LANG.orderpaymenttermfree}{else}{$configoption.recurring}{/if}

if you just need it in the one language, swap the language string for text...

 

{if $configoption.recurring eq '0,00€'}Free{else}{$configoption.recurring}{/if}

if you're only using one currency in WHMCS, then just adjust the above to suit your currency format - if you're using multiple currencies, then you can use...

 

{if $configoption.recurring eq "{$currency.prefix}0,00{$currency.suffix}"}{$LANG.orderpaymenttermfree}{else}{$configoption.recurring}{/if}

in fact, if you were using multiple currencies with multiple number formats, you could expand the above further... but I assume that you're not, so let's not bother! :)

Link to comment
Share on other sites

if you wanted to make it multilingual, i'd be more tempted to use...

 

{if $configoption.recurring eq '0,00€'}{$LANG.orderpaymenttermfree}{else}{$configoption.recurring}{/if}

if you just need it in the one language, swap the language string for text...

 

{if $configoption.recurring eq '0,00€'}Free{else}{$configoption.recurring}{/if}

if you're only using one currency in WHMCS, then just adjust the above to suit your currency format - if you're using multiple currencies, then you can use...

 

{if $configoption.recurring eq "{$currency.prefix}0,00{$currency.suffix}"}{$LANG.orderpaymenttermfree}{else}{$configoption.recurring}{/if}

in fact, if you were using multiple currencies with multiple number formats, you could expand the above further... but I assume that you're not, so let's not bother! :)

 

Amazing!! Works perfect, thanks a lot!

Link to comment
Share on other sites

Is there a way to get the Configurable Option Groups Name or the Configurable Option Groups Description?

there's nearly always a way to do most things with WHMCS - it just depends how much effort you want to put in! :)

 

it's worth remembering that the documentation says that the Configurable Options Group Names and Descriptions are for admin reference only - so they certainly won't be passed to the cart as Smarty variables.

 

however, as the information will be stored in the database, if you have to get them you could query the database to get them - either via hook, or perhaps even a data feed.

 

I suspect it would slightly easier in configureproduct.tpl because there you would have access to the configurable option ID value - so you'd be able to query the db to get the groupname... whereas in the order summary, there are no config ID, so you'd be left to search based on the config name, which is ok if it's unique... but if you had more than one config option with the same name (or more than one without a name!), that might cause issues.

 

but the best solution will depend upon where exactly you want to use them... :?:

Link to comment
Share on other sites

there's nearly always a way to do most things with WHMCS - it just depends how much effort you want to put in! :)

 

it's worth remembering that the documentation says that the Configurable Options Group Names and Descriptions are for admin reference only - so they certainly won't be passed to the cart as Smarty variables.

 

however, as the information will be stored in the database, if you have to get them you could query the database to get them - either via hook, or perhaps even a data feed.

 

I suspect it would slightly easier in configureproduct.tpl because there you would have access to the configurable option ID value - so you'd be able to query the db to get the groupname... whereas in the order summary, there are no config ID, so you'd be left to search based on the config name, which is ok if it's unique... but if you had more than one config option with the same name (or more than one without a name!), that might cause issues.

 

but the best solution will depend upon where exactly you want to use them... :?:

 

Thanks, good to know that it is only for admin reference only. In that case I will use the easy way ;)

 

Another question I have about the cart is, how can I check if one of the domains in the cart does have or does not have hosting and does have or does not have a eppcode?

 

I tried something like this, but that does not seem to work:

 

{if $domain.hosting}

code if some products product got hosting

{/if}

 

{if $domain.eppenabled}

code if some products product got epp enabled

{/if}

 

How can I achieve this?

 

In total I want the following code:

 

{if $domain.eppenabled}

code if some product got epp enabled

{elseif $domain.hosting}

code if some product do not have epp enabled but do have hosting

{else}

code if none product got hosting or epp enabled

{/if}

 

How can I achieve that?

Link to comment
Share on other sites

In total I want the following code:

 

{if $domain.eppenabled}

code if some product got epp enabled

{elseif $domain.hosting}

code if some product do not have epp enabled but do have hosting

{else}

code if none product got hosting or epp enabled

{/if}

 

How can I achieve that?

aren't they boolean variables? if so, you should need...

 

{if $domain.eppenabled eq true}
code if some domain (transfer) got epp enabled
{elseif $domain.eppenabled eq false and $domain.hosting eq true}
code if some domain do not have epp enabled but do have hosting
{else}
code if domain has neither
{/if}

but adding {debug} to the end of the template will be a useful tool to tell you which arrays/variables are available in a particular template. :idea:

Link to comment
Share on other sites

aren't they boolean variables? if so, you should need...

 

{if $domain.eppenabled eq true}
code if some domain (transfer) got epp enabled
{elseif $domain.eppenabled eq false and $domain.hosting eq true}
code if some domain do not have epp enabled but do have hosting
{else}
code if domain has neither
{/if}

but adding {debug} to the end of the template will be a useful tool to tell you which arrays/variables are available in a particular template. :idea:

 

Thanks a lot!

 

I tried that, but that does not seem to work.

 

I also tried the {debug} but that does not display any additional information on the page.

 

Am I missing something?

Link to comment
Share on other sites

I tried that, but that does not seem to work.

this is why WHERE you're trying to do this is important... if the variables don't exist, it won't work!

 

they'd likely exist on configuredomains.tpl, but i'm not sure if they would elsewhere... you'd have to check with a {debug}

 

I also tried the {debug} but that does not display any additional information on the page.

Am I missing something?

if you added it to the correct template, then it should create a popup window - I can only assume you added it to the wrong template and/or you've got a popup blocker active in your browser.

Link to comment
Share on other sites

this is why WHERE you're trying to do this is important... if the variables don't exist, it won't work!

 

they'd likely exist on configuredomains.tpl, but i'm not sure if they would elsewhere... you'd have to check with a {debug}

 

 

if you added it to the correct template, then it should create a popup window - I can only assume you added it to the wrong template and/or you've got a popup blocker active in your browser.

 

Thanks, the pop up block was indeed the problem!

It works fine.

 

But I see that the values are really there in the popup, but the code does not seem to work.

I got the following values, but the code inside the {else} is displayed.

It should display the code inside the {elseif $domain.eppenabled eq false and $domain.hosting eq true}

 

domain => "domain.com"

regperiod => "1"

dnsmanagement => "on"

emailforwarding => ""

idprotection => ""

addonsCount => 1

dnsmanagementselected => false

emailforwardingselected => false

idprotectionselected => false

eppenabled => false

eppvalue => ""

fields => Array (0)

configtoshow => true

hosting => true

Link to comment
Share on other sites

seems to be working for me - epp is false, hosting is true...

 

http://prntscr.com/bgcrix

 

there is a potential flaw in that if epp is false and hosting is false, it will do nothing... though perhaps you want it to.

 

you could try putting the false and true in single quotes or each multiple condition in brackets, but it's working fine for me with neither.

Link to comment
Share on other sites

Hmm strange!

 

I tried that and I still get code if domain has neither.

Even when hosting is true.

 

Do you load it within the {foreach key=num item=domain from=$domains}?

 

Because than it works, but that's the problem.

It then checks it for each domain, but I want it to check for the total domains.

Edited by JelleG
Link to comment
Share on other sites

Do you load it within the {foreach key=num item=domain from=$domains}?

no I just threw it at the end of the template - but it shouldn't matter as there was only one domain in the cart when I tried it!

 

Because than it works, but that's the problem.

It then checks it for each domain, but I want it to check for the total domains.

and you couldn't have mentioned that small detail earlier! :roll:

 

so just to check I have it right, what you want to check for is the following?

 

*if there is at least one domain with EPP enabled in the cart*
code if some domain got epp enabled
* elseif no domains have EPP but at least one has hosting*
code if some domain do not have epp enabled but do have hosting
*else*
code if all domains have neither
*/if*

Link to comment
Share on other sites

no I just threw it at the end of the template - but it shouldn't matter as there was only one domain in the cart when I tried it!

 

 

and you couldn't have mentioned that small detail earlier! :roll:

 

so just to check I have it right, what you want to check for is the following?

 

*if there is at least one domain with EPP enabled in the cart*
code if some domain got epp enabled
* elseif no domains have EPP but at least one has hosting*
code if some domain do not have epp enabled but do have hosting
*else*
code if all domains have neither
*/if*

 

Yeah, sorry! Should mentioned that before.

 

That is exactly the code I need.

 

Do you know how I can achieve that?

Link to comment
Share on other sites

Do you know how I can achieve that?

well if you want to avoid the need to get involved with code that searches the arrays, and seeing as you're editing the template anyway - the simpler way to do it in Smarty might be to do it in two parts... in the foreach loop, use if statements to assign flag variables if conditions are true... and then outside of the loop, check if those variables exist and respond accordingly...

 

so inside the foreach loop...

 

{if $domain.eppenabled eq true}{$eppflag=true}{/if}
{if $domain.hosting eq true}{$hostingflag=true}{/if}

and then outside of the loop...

 

{if isset($eppflag)}
code if any domain has got epp enabled
{elseif !isset($eppflag) and isset($hostingflag)}
code if no domains have epp, but at least one has hosting
{else}
code if no domains have either
{/if}

you shouldn't really need to check the values of these flag variables - either they'll exist and be true if created by the {if} statements, or if the {if} statements are never triggered, they won't exist.

 

btw - you don't have to set these flag variables to true, you could set them to anything really - brian, JelleG, false etc - as long as they are assigned a value, then the variable exists and that's all you need for this task.

 

it should work fine with multiple items in the cart, but test it to make sure! :idea:

Link to comment
Share on other sites

what if we choose only annually price for specific configuration option to be displayed in annually price option.

which template file do we need to modify configureproduct.tpl or ordersummery.tpl and How...can you jot some examples here... will be useful for all whmcs clients...lol

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