Jump to content

[Blesta 3.2.1-3.5.1] Universal Module Workaround 2: Hide Certain Service Fields From Being Shown On Order Page


Rodrigo

Recommended Posts

This patch should help to use the Universal Module for manually provisioning services that need administrators to fill service fields with data after they do the activation. e.g. dedicated servers, IP needs to be shown at control panel after the service is activated, but it shouldn't be asked at order page.

Requirements.
- Blesta 3.2.1

Update: I Upgraded to Blesta 3.5.1 and It worked fine

Instructions:
1. Open components/modules/universal_module/universal_module.php

Find:

        public function getClientAddFields($package, $vars=null) {
                // Same as admin
                return $this->getAdminAddFields($package, $vars);
        }

Replace with:

	public function getClientAddFields($package, $vars=null) {
                $fields = new ModuleFields();
                
                if (!isset($vars->meta))
                        $vars->meta = array();
                
                if (isset($package->module_row) && $package->module_row > 0) {
                        $row = $this->getModuleRow($package->module_row);
                        
                        // Set the module row, which will allow us to reference it later when getName() is invoked
                        $this->setModuleRow($row);
                        
                        $row_fields = array();
                        if ($row->meta) {
                                $row_fields = $this->formatModuleRowFields($row->meta);
                                
                                $field_data = array();
                                // Reformat package fields into a more usable format
                                foreach ($row_fields['service_fields'] as $key => $values) {
                                        foreach ($values as $i => $value) {
                                                $field_data[$i][$key] = $value;
                                        }
                                }
                                $newfield_data = array();
                                foreach($field_data as $field) {
                                  if(strpos($field['name'], "dontask_") !== false) {
                                    continue;
                                  }
                                  $newfield_data[] = $field;
                                }
                                $this->setModuleFields($fields, $newfield_data, $vars);
                        }
                }
                return $fields;

	}

2. Add "_dontask" in any part of the service field name

3. Protip: you should combine this patch with Universal Module Workaround: Show Service Fields At Client Panel , for best experience.

 

Preview (Using both patches):

 

Setting up Universal Module for showing certain service fields in Client's Manage Service (Workaround 1) and Hiding some service fields from being asked at order page

GxhTVC7.png

 

Order Page with hidden fields

h6obKX5.png

Admin CP: Manually activating service, all fields being shown

hZsGNpR.png

Fields Shown to Client (Workaround 1 + 2)

48EPrRS.png

 

Download universal_module.php with both workarounds applied (Only for Blesta 3.2.1):  universal_module.php

Link to comment
Share on other sites

  • 2 weeks later...
  • 9 months later...

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...