Katamaze / WHMCS-Action-Hook-Factory

Free collection of Action Hooks, Reports and Modules to perfect your WHMCS
https://katamaze.com
MIT License
210 stars 84 forks source link

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

Open billfoo opened 3 years ago

billfoo commented 3 years ago

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/

Kian987 commented 3 years ago

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

billfoo commented 3 years ago

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

billfoo commented 3 years ago

Replace ClientAreaPage with ClientAreaPageCart seems fixed.

Kian987 commented 3 years ago

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.

billfoo commented 3 years ago

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

Kian987 commented 3 years ago

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

billfoo commented 3 years ago

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)