Jump to content

Removing cost from "Choose Billing Cycle"


Ragonz

Recommended Posts

Hello Ragonz,

 

Under Setup -> Products/Services -> Products/Services -> YOUR SERVICE -> Pricing untick the enable box under Quarterly or set the price on this pricing level then save

 

Unfortunately its not that simple as the billing frequency box is required, the price comes from configurable options. I dont want to know how to remove the options entirely, just to remove the $0.00 from the end.

Link to comment
Share on other sites

that x% discount in the billing cycle text is not the usual WHMCS format, so I assume there is an addon modifying the output - and after looking at your website, this only seems to occur on your TeamSpeak3 product, therefore I would imagine the Smarty variable is being modified by that addon... first thought would be to contact the developers and see if it can be tweaked by them.

 

assuming they can't, you should be able to do it yourself by editing the standard_cart/configureproduct.tpl template... there'd be a few ways to do it in Smarty, but one simple way would be to just remove the final 11 characters from the output - e.g by changing....

 

                                        {if $pricing.quarterly}
                                           <option value="quarterly"{if $billingcycle eq "quarterly"} selected{/if}>
                                               {$pricing.quarterly}
                                           </option>
                                       {/if}

with...

 

                                        {if $pricing.quarterly}
                                           <option value="quarterly"{if $billingcycle eq "quarterly"} selected{/if}>
                                               {if $productinfo.pid eq '87'}{$pricing.quarterly|substr:0:-11}{else}{$pricing.quarterly}{/if}
                                           </option>
                                       {/if}

that should get rid of " - £0.00GBP" and do the same for Euro and USD pricing too... then do the same with the semiannually and annually billing cycles {if} blocks of code. :!:

Link to comment
Share on other sites

  • 3 weeks later...

The issue occurs with all products not just TS3, where would I find standard_cart/configureproduct.tpl as I cant see it within our template files. The module we are using doesn't touch the ordering side it only connects WHMCS to TCAdmin (As far as I am aware)

 

- - - Updated - - -

 

nevermind about finding it now, have located it, issue occurs with all products though so would

{if $pricing.quarterly}
                                           <option value="quarterly"{if $billingcycle eq "quarterly"} selected{/if}>
                                               {if $productinfo.pid eq '*'}{$pricing.quarterly|substr:0:-11}{else}{$pricing.quarterly}{/if}
                                           </option>
                                       {/if}  

 

work?

Link to comment
Share on other sites

  • 4 weeks later...
  • 4 years later...
40 minutes ago, Ragonz said:

How do I go about making sure the billing cycle just displays

two simple options... either edit the template and replace the output for each cycle with it's language string equivalent, e.g

                                        {if $pricing.monthly}
                                            <option value="monthly"{if $billingcycle eq "monthly"} selected{/if}>
                                                {$pricing.monthly}
                                            </option>
                                        {/if}

becomes...

                                        {if $pricing.monthly}
                                            <option value="monthly"{if $billingcycle eq "monthly"} selected{/if}>
                                                {$LANG.orderpaymenttermmonthly}
                                            </option>
                                        {/if}

and then repeat for the other billing cycles...

or you use an action hook to modify those values in a similar way and remove the need to edit the template...

<?php

# Remove Pricing From Cart BillingCycles Hook
# Written by brian!

use WHMCS\Config\Setting;

function cart_remove_prices_in_billingcycles_hook($vars) {
	
	$pricebreak = Setting::getValue('ProductMonthlyPricingBreakdown');
	if ($vars['templatefile'] == 'configureproduct' && empty($pricebreak)) {		
		$pricing = $vars['pricing'];
		$cyclesarray = array('monthly','quarterly','semiannually','annually','biennially','triennially');
		foreach ($cyclesarray as $cycle) {
			if ($pricing[$cycle]) {
				$langstring = 'orderpaymentterm'.$cycle;
				$pricing[$cycle] = Lang::trans($langstring);
			}
		}
		return array("pricing" => $pricing);
	}
}
add_hook("ClientAreaPageCart", 1, "cart_remove_prices_in_billingcycles_hook");

the above hook first checks to see if Monthly Pricing Breakdown in enabled in the settings, and if not, then it will modify the available cycle values... if you want to make the change regardless of MPB setting, then you can just remove that condition from the code.

Link to comment
Share on other sites

On 3/2/2021 at 2:47 PM, brian! said:

two simple options... either edit the template and replace the output for each cycle with it's language string equivalent, e.g


                                        {if $pricing.monthly}
                                            <option value="monthly"{if $billingcycle eq "monthly"} selected{/if}>
                                                {$pricing.monthly}
                                            </option>
                                        {/if}

becomes...


                                        {if $pricing.monthly}
                                            <option value="monthly"{if $billingcycle eq "monthly"} selected{/if}>
                                                {$LANG.orderpaymenttermmonthly}
                                            </option>
                                        {/if}

and then repeat for the other billing cycles...

or you use an action hook to modify those values in a similar way and remove the need to edit the template...


<?php

# Remove Pricing From Cart BillingCycles Hook
# Written by brian!

use WHMCS\Config\Setting;

function cart_remove_prices_in_billingcycles_hook($vars) {
	
	$pricebreak = Setting::getValue('ProductMonthlyPricingBreakdown');
	if ($vars['templatefile'] == 'configureproduct' && empty($pricebreak)) {		
		$pricing = $vars['pricing'];
		$cyclesarray = array('monthly','quarterly','semiannually','annually','biennially','triennially');
		foreach ($cyclesarray as $cycle) {
			if ($pricing[$cycle]) {
				$langstring = 'orderpaymentterm'.$cycle;
				$pricing[$cycle] = Lang::trans($langstring);
			}
		}
		return array("pricing" => $pricing);
	}
}
add_hook("ClientAreaPageCart", 1, "cart_remove_prices_in_billingcycles_hook");

the above hook first checks to see if Monthly Pricing Breakdown in enabled in the settings, and if not, then it will modify the available cycle values... if you want to make the change regardless of MPB setting, then you can just remove that condition from the code.

this hook not work form me on 8.1.3

 

@Brian guru where is the problem ?

Link to comment
Share on other sites

2 hours ago, tangogc said:

this hook not work form me on 8.1.3

@Brian guru where is the problem ?

because I think your site has Monthly Pricing Breakdown enabled and so the hook ignores those cycles... as I explained would happen at the end of the last post. 🙂

DqSmJ3n.png

to make it work regardless of the MPB setting, you could just change that first if statement to...

if ($vars['templatefile'] == 'configureproduct') {	
Link to comment
Share on other sites

thanks Brian as usual, but not work too.

and also are we sure that remove only the 0.00 price ? and not also where the mounthly prices are defined ?

 

<?php

# Remove Pricing From Cart BillingCycles Hook
# Written by brian!

use WHMCS\Config\Setting;

function cart_remove_prices_in_billingcycles_hook($vars) {
    
    $pricebreak = Setting::getValue('ProductMonthlyPricingBreakdown');
    if ($vars['templatefile'] == 'configureproduct') {        
        $pricing = $vars['pricing'];
        $cyclesarray = array('monthly','quarterly','semiannually','annually','biennially','triennially');
        foreach ($cyclesarray as $cycle) {
            if ($pricing[$cycle]) {
                $langstring = 'orderpaymentterm'.$cycle;
                $pricing[$cycle] = Lang::trans($langstring);
            }
        }
        return array("pricing" => $pricing);
    }
}
add_hook("ClientAreaPageCart", 1, "cart_remove_prices_in_billingcycles_hook");

Link to comment
Share on other sites

16 minutes ago, tangogc said:

thanks Brian as usual, but not work too.

I assume you are uploading it to the existing /includes/hooks folder, and within it's own .php file ?

18 minutes ago, tangogc said:

and also are we sure that remove only the 0.00 price ?

it's replacing the entire content of each dropdown option with it's language string equivalent....

1RsOO0w.png

20 minutes ago, tangogc said:

and not also where the monthly prices are defined ?

no the dropdown is just a label that passes the cycle value.

Link to comment
Share on other sites

16 hours ago, tangogc said:

somethings in the code is wrong I have attached the hook

the hook code is working fine - I tested it before posting and if I upload your attached hook to my hooks folder (and disable mine), then it works without issue - only differences I can see are the filesize and possibly the encoding of the file.

if you can't get the hook to work, then you can do this in the template manually...

                                        {if $pricing.monthly}
                                            <option value="monthly"{if $billingcycle eq "monthly"} selected{/if}>
                                                {$pricing.monthly}
                                            </option>
                                        {/if}

becomes...

                                        {if $pricing.monthly}
                                            <option value="monthly"{if $billingcycle eq "monthly"} selected{/if}>
                                                {$LANG.orderpaymenttermmonthly}
                                            </option>
                                        {/if}

and then repeat for the other cycles.

cpNbePp.png

Link to comment
Share on other sites

16 hours ago, tangogc said:

There is anyway to debug the hook and understand why not work ?=

there is nothing wrong with the hook - the issue will be that you have other conflicting cart changes occurring...

I can see from the site that there are other modifications occurring in the output - they might be template changes, other hooks or even ModuleGarden's Discount Center addon - any of which could be interfering with the hook (e.g running after the hook and undoing the changes).

Link to comment
Share on other sites

55 minutes ago, tangogc said:

yes you right "as usual" Discount center" break the hook.

you could try changing the hook priority so that perhaps the hook should run after the MG addon...

add_hook("ClientAreaPageCart", 100, "cart_remove_prices_in_billingcycles_hook");

... but i'm not sure if that will have any affect as I don't have the MG addon locally to test.

Link to comment
Share on other sites

thans Brian as someone alredy said I will have to offer you a virtual coffy 🙂

No replacing the hook priority not solve the problem, only disabling the module it work again.

if you are interested to test all MG extension can be download for a free 7 days testing but need to complete the registration process.

 

Thanks

 

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