Jump to content

[How-to] Add Privacy protection to logicboxes module


Blesta Addons

Recommended Posts

Hello Blestars,alot of users ask for the privacy protection , i will sgare with you what i have done in my blesta system to support privacy protection, this tuto is broought to you by Blesta-addons , the source link is located here add privacy protection to Logicboxes module .

1 - First we need to add Configurable Options Group, let call it Protection ID
2 - Create Configurable Options , type checkbox, with Client can Add and Edit, in label put what you want like 'Privacy Protection', in name you should put 'purchase-privacy', in option set the name and in value put 'true' , set price, select group 'Protection ID' . a screen shot like this

protection_id_1.png

 

3 - Now, edit the domain package to support Configurable Options that we have added, save .

at here we have finished the easy task, now we will attack the hard part, as we need to add some code in the logicboxes Module , we should open components/modules/logicboxes/logicboxes.php , in addService() function then search

            $domain_field_basics = [
                'years' => true,
                'ns' => true,
                'customer-id' => true,
                'reg-contact-id' => true,
                'admin-contact-id' => true,
                'tech-contact-id' => true,
                'billing-contact-id' => true,
                'invoice-option' => true,
                'protect-privacy' => true
            ];

 

Replace with

             $domain_field_basics = [
                'years' => true,
                'ns' => true,
                'customer-id' => true,
                'reg-contact-id' => true,
                'admin-contact-id' => true,
                'tech-contact-id' => true,
                'billing-contact-id' => true,
                'invoice-option' => true,
                'protect-privacy' => true,
                'purchase-privacy' => true
            ];

 

Search

                $vars['invoice-option'] = 'NoInvoice';
                $vars['protect-privacy'] = 'false';

 

replace with

                $vars['invoice-option'] = 'NoInvoice';
                $vars['protect-privacy'] = 'false';
                $vars['purchase-privacy'] = 'false';

 

search

$response = $domains->register(array_intersect_key($vars, $domain_fields));

replace with

                    // Add Protect privacy to the domain
                    if (isset($vars['configoptions']['purchase-privacy'])) {
                        $vars['protect-privacy'] = 'true';
                        $vars['purchase-privacy'] = 'true';
                    }
                    
                    $response = $domains->register(array_intersect_key($vars, $domain_fields));

 

in editService() function, search

$service_fields = $this->serviceFieldsToObject($service->fields);

 

under add

        // Set any config options
        $vars['configoptions'] = (isset($vars['configoptions']) ? (array)$vars['configoptions'] : null);
        
        // Only provision the service if 'use_module' is true
        if ($vars['use_module'] == 'true') {
        
            // Update config option fields
            if (isset($vars['configoptions'])) {
                
                $response = $domains->details(
                    ['order-id' => $service_fields->{'order-id'}, 'options' => ['OrderDetails']]
                );
                $this->processResponse($api, $response);
                $order = $response->response();
                
                // Add Protect privacy to the domain if applicable
                if ($vars['configoptions']['purchase-privacy']
                    && ($order->privacyprotectedallowed == 'true')
                    && ($order->isprivacyprotected == 'false')
                ) {
                    $data = array(
                        'order-id' => $service_fields->{'order-id'},
                        'invoice-option' => 'NoInvoice'
                    );

                    $response = $domains->purchasePrivacy($data);
                    $this->processResponse($api, $response);
                }                
            }
            
            if ($this->Input->errors()) {
                return;
            }
        }

 

in renewService() function , search

            $vars = [
                'years' => 1,
                'order-id' => $fields->{'order-id'},
                'exp-date' => $order->endtime,
                'invoice-option' => 'NoInvoice'
            ];

 

under add

            // Rnew Privacy protection if added to the domain
            if (isset($service->options) ) {
                foreach ($service->options as $option) {
                    if (($option['option_name'] == 'purchase-privacy')
                        && ($order->privacyprotectedallowed)
                    ) {
                        $vars['purchase-privacy'] = 'true';
                    }
                }
            }

 

save the change, now you are done .

if blesta team found this helpfull i hope they can add it to the official module .

Link to comment
Share on other sites

I have one question.

Let's say the customer already has a domain registered without privacy and they add privacy today and the 1 year charge is $4. Their domain does not expire for 5 more years. Will this charge $4 to the customer or will it calculate properly so that 5 years are charged for?

Link to comment
Share on other sites

8 minutes ago, evolvewh said:

I have one question.

Let's say the customer already has a domain registered without privacy and they add privacy today and the 1 year charge is $4. Their domain does not expire for 5 more years. Will this charge $4 to the customer or will it calculate properly so that 5 years are charged for?

Not tested, but the price calculation is something related to blesta not to modules.

Link to comment
Share on other sites

On 08/18/2017 at 9:32 PM, evolvewh said:

I have one question.

Let's say the customer already has a domain registered without privacy and they add privacy today and the 1 year charge is $4. Their domain does not expire for 5 more years. Will this charge $4 to the customer or will it calculate properly so that 5 years are charged for?

After a test it has. The privacy price is for the remaining years to expiry .

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.

Loading...
×
×
  • Create New...