Jump to content
  • 0

Service custom field blesta


liveb

Question

Hello,

I'm looking for a solution to add custom field for each product or package where i can set custom value for each client.
I tried that with 2 ways but it's not working well 

 

first way: i used universal addon where i set package and service option for each product but that's not working because those custom fields displayed on order form
note: i need those custom fields  displayed after activating the services like licence provider from third party without api automation.

this way will work for me if any one can help me to hide those custom fields from order form.

second way is by creating a configurable option this is a better way but the issue of this way each custom fields contain $ fee 
so i set 0$ for each configurable option so when client check the service will see each custom field come with 0$ symbol 
so i'm looking to disable or hide the fee of 0$ for each configurable option (note: when i want to add a new configurable option with additional cost i need to be displayed  but when i set the value of cost to 0 i need to get  nothing displayed about the configurable option cost)
i want to show configurable option without $ or 0$

I apologize for the prolonged or repeated speech
I hope that my question is clear

awaiting a reply

thanks 
 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

If you were using the Universal Module, you could create a Service Option of the type "Hidden". That will not be visible to clients, and will not appear on the order form, however, an admin can see/update that field in the staff UI.

If using a configurable option, those will always be shown to clients, and will always display their prices. It would require a number of source code updates to disable that behavior.

Can either of those work with your use case?

Link to comment
Share on other sites

  • 0

Hello,  Tyson

Great it work perfectly with universal module and Hidden type.

For this topic to be a reference for Blesta users
Let me assure you that this is not enough

To get those custom filed visible for clients on client area  also it  require to update  the universal_module.php file code 

File location:  blesta_root_folder/components/modules/universal_module/universal_module.php

first 

we need to find the following code 
 

 private function isUrl($str)
    {
        return preg_match("#^\S+://\S+\.\S+.+$#", $str);
    }

then we need to add the following code  (bellow the above code)

 

   /**
         * Returns all tabs to display to a client when managing a service whose
         * package uses this module
         *
         * @param stdClass $package A stdClass object representing the selected package
         * @return array An array of tabs in the format of method => title. Example: array('methodName' => "Title", 'methodName2' => "Title2")
         */
        public function getClientTabs($package) {
                return array(
                        'moreinfo' => array('name' => "More Info", 'icon' => "fa fa-gears")
                );
        }
    /**
     * The More Info tab
     *
     * @param stdClass $package A stdClass object representing the current package
         * @param stdClass $service A stdClass object representing the current service
         * @param array $get Any GET parameters
         * @param array $post Any POST parameters
         * @param array $files Any FILES parameters
         * @return string The string representing the contents of this tab
     */
    public function moreinfo($package, $service, array $get=null, array $post=null, array $files=null) {
         $row = $this->getModuleRow($package->module_row);
         $out = '';
         $servicefields = array();
         foreach ($row->meta as $key=>$value ) {
              if (strpos($key, "service_field_name") !== false) {
                // Here we match the service field label with their key and value
                foreach($service->fields as $field) {
                  if($field->key == $value) {
                     $name = 'service_field_label_' . str_replace('service_field_name_', '', $key);
                     $servicefields[] = array("label" => $row->meta->$name,
                                              "key" => $value,
                                              "value" => $field->value); 
                  }
                }
              }
         }

         foreach($servicefields as $field) {
            // Filter out for showing only public fields
            if(strpos($field['key'], "public_") === 0 ) {
              $out .= "<p><b>". $field['label'] . ":</b> " . $field['value'] . "</p>"; 
            }
         }
         return "<h4>Service Details</h4><br />" . $out ;
  
    }

Thank you very much

if possible can you share the code to hide the cost of configurable option of package when we set the cost (of configurable option) equal to 0.
Greeting 

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
Answer this question...

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