WHMCS-Action-Hook-Factory icon indicating copy to clipboard operation
WHMCS-Action-Hook-Factory copied to clipboard

[Feature Request] Remove options in the "X years" dropdown depending on TLD

Open billfoo opened this issue 5 years ago • 7 comments

My Registrar sends via "TLD Import & Pricing Sync" Pricing always for 10 Years but some of this Domains are on Sale (1$ or 2$). Sale-Domains can be registered as New only for 1 Year, and Renew is for multiple Years possible again.

  1. Register only 1 Year on specific Domains as an Option and Renew 1-5 Years

  2. Sync "TLD Import & Pricing Sync" every day automatically

https://whmcs.community/topic/303608-domain-tld-filter-years-register-renew/

billfoo avatar Nov 27 '20 17:11 billfoo

This hook is my first attempt. It removes domain billing cycles based on TLD.

Kian987 avatar Nov 28 '20 04:11 Kian987

Working if u are not logged in. For logged in Customers there is no change

billfoo avatar Nov 28 '20 12:11 billfoo

Replace ClientAreaPage with ClientAreaPageCart seems fixed.

billfoo avatar Nov 28 '20 12:11 billfoo

Let's ignore for a moment the hook point.

In my first attempt I was focusing just on cart.php. There's another page where we need to add the same restrictions. I'm referring to "Renew Domain" page. The updated version of the hook restricts billing cycles for both pages. Please try it and let me know.

Kian987 avatar Nov 28 '20 14:11 Kian987

Replacing with new Version of Code doesn't work anymore. New and Renew too.

billfoo avatar Nov 28 '20 20:11 billfoo

Please, post me your configuration. Basically I need to know the values of $restrictedTLDs and $restrictedPeriods variables.

Kian987 avatar Nov 29 '20 14:11 Kian987

This is my Config:

add_hook('ClientAreaPage', 1, function($vars) { if (($vars['filename'] == 'cart' AND $_GET['a'] == 'view') OR $vars['templatefile'] == 'domain-renewals') { $restrictedTLDs = array('.com', '.net', '.org', '.eu', '.info', '.store', '.xyz', '.work', '.top', '.icu', '.cloud', '.club', '.click', '.business', '.asia', '.art', '.company', '.cyou', '.in', '.io'); // Specify TLD for which you want to restrict billing cycles. TLD must start with a dot "." $restrictedPeriods = array('2', '3', '4', '5', '6', '7', '8', '9', '10'); // Any value from 1 to 10 (1 year, 2 years, 3 years... 10 years)

billfoo avatar Nov 29 '20 21:11 billfoo