Jump to content
  • 0

Interacting with the Universal Module programatically.


coreyman

Question

Can you interact with the universal module programatically? For example, when you create a service and there are fields required from the universal module how are those entered? Do you use configoptions An array of key/value pairs of package options where the key is the package option ID and the value is the option value  listed at http://source-docs.blesta.com/class-Services.html under vars? If so can we get an example snippet of passing configoptions ?

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

The other guys may be able to comment regarding the code, but the universal module does not really do anything with config options. Universal Module Product "Service Fields" are requested during checkout, and useful for fields like "Domain" or "Hostname" where you must ask for the field, but do not want any impact on price. As of Blesta 4.4 you can create text/textarea/password config option fields with a price of $0.00 but it may still be preferable to use a Universal Module Product Service Field instead.

I don't know if that helps, but I hope it added some clarity to the way it works, hopefully someone else can more fully answer your question.

Link to comment
Share on other sites

  • 0
16 hours ago, Paul said:

As of Blesta 4.4 you can create text/textarea/password config option fields with a price of $0.00 but it may still be preferable to use a Universal Module Product Service Field instead.

I'd be open to using just text config option fields as well if it's easier to work with programatically. I'm guessing these are the arguments passed in the configoptions array and not the universal module service fields.

Link to comment
Share on other sites

  • 0
1 hour ago, coreyman said:

I'd be open to using just text config option fields as well if it's easier to work with programatically. I'm guessing these are the arguments passed in the configoptions array and not the universal module service fields.

Using config options will probably be more difficult since it uses pricing and needs to be set based on the service's term/period. There is a lot more complexity in config options compared with universal module product service fields.

19 hours ago, coreyman said:

Can you interact with the universal module programatically? For example, when you create a service and there are fields required from the universal module how are those entered? Do you use configoptions An array of key/value pairs of package options where the key is the package option ID and the value is the option value  listed at http://source-docs.blesta.com/class-Services.html under vars? If so can we get an example snippet of passing configoptions ?

The universal module looks for fields in a meta array. It does not use configoptions, since those represent different data entirely.

For example, if you are creating a universal module product, under the "Service Options" section you can set fields. I could set a "Hostname" Label with a "hostname" Name of the "Text" Type. The Name field represents the key for that option, and the value entered by the customer is that key's value (e.g. 'hostname' => 'mydomain.com'). When you add this through a call to Services::add() in $vars, it would look similar to:

$vars = [
	'client_id' => 1,
	...
	'meta' => [
		'hostname' => 'mydomain.com'
	]
];

$services = ...; // set to an instance of the Services end-point
$services->add($vars);

 

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