I have been trying to create order programatically, it's working well except custom option.
I have one custom option which reference id is 435. I have tried the following. But it seems not working
$order->setData(array(
'options' => array(
435 => $customvalue,
)
));
I got above suggestion From here
How to save custom option field value when create order programatically?
I got an answer for my question from here
Its working rock
$existentOptions['additional_options'][] = array(
'label' => $optiontitle, // Title of custom option field
'value' => $customvalue, // Value of custom option field
);
For more details, you can check on my blog here
Related
I am trying to build an stylable widget that loads with preset or default styling values when introduced to a page. I have been able to utilize default=”” within the form fields to achieve this effect on all buttons and text. But I am trying to establish a background image that will load in initially and allow the user to change the image through the provided fields. Is there a way to set a default image value in my field setting to achieve this functionality? I have provided my attempt below to better demonstrate my goal.
‘fields’ => [
‘image’ => [
‘type’ => ‘media’,
‘label’ => __(‘Image’, ‘widgets-bundle’),
‘choose’ => __(‘Choose image’, ‘widgets-bundle’),
‘update’ => __(‘Set image’, ‘widgets-bundle’),
‘default’ => ‘exampel.org/wp-
content/uploads/2021/05/randomimage_2560x890.jpg’,
‘library’ => ‘image’,
‘fallback’ => true,
],
...
]
Thank you!
Unfortunately, the Media Field doesn't currently support defaults at this time. Your best bet for doing this would be to either create a custom field that allows for this, or alter the base custom field using the siteorigin_widgets_field_registered_class_paths hook. That hook allows you to override the base form field main file with a file of your choosing so you can use it to introduce additional features or control defaults. The documentation for this filter is still pending, but you can find the current version here.
I'm trying to make a TextArea field in the Opportunities module show only a single row of data then allow the user to scroll through the remaining data. How can this be done?
I have looked this up here on Stack Overflow but cannot seem to make this work.
I am using SugarCRM CE version 6.5.13
Thanks.
Create the file if it doesn't already exist:
custom/modules/Opportunities/metadata/editviewdefs.php
Within the edit view definition file you can use displayParams to change or add attributes to a specific field. For instance, I added the attribute 'rows' and made it 1 row (it can still expand).
6 =>
array (
0 =>
array (
'name' => 'description',
'label' => 'LBL_DESCRIPTION',
'displayParams' =>
array (
'rows' => 1,
),
),
),
Hope this helps.
I have created a custom post type wrestling and created its corresponding custom fields using Advanced Custom Fields. Now, I wanted the users to fill this custom form on the front end, so that on submission, the data would get automatically updated in the custom post type in the dashboard. For this purpose, I created a custom page and assigned a custom template to it which contained the required form. There are four HTML form fields that the users are supposed to fill, named name, venue, main_event and fee respectively.
The custom form fields that I created using Advanced Custom Fields are named as promotion_name, venue, main_event_ and price respectively. Now, in order to fill the data entered by the users on the front end onto the custom post type fields at the dashboard, I tried using the wp_insert_post() function as follows:
$post_information = array(
'promotion_name' => $_POST['name'],
'venue' => $_POST['venue'],
'main_event_' => $_POST['main_event'],
'price' => $_POST['fee'],
'post_type' => 'wrestling',
);
wp_insert_post( $post_information );
However, after the user submits the form, a new entry (no_title) does appear in my custom post type, but the custom form fields are still empty (See images below:)
I'm sure this is because I'm not using the wp_insert_post() correctly for updating custom post types. I'd really appreciate some help here. Thanks.
PS: This is how I have defined my custom post type in functions.php:
<?php
function wrestling_show_type()
{
register_post_type('wrestling',
array('labels' => array('name' => 'Wrestling Shows', 'singular_name' => 'Wrestling Show'),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'wrestling')));
flush_rewrite_rules();
}
add_action('init', 'wrestling_show_type');
?>
If you have used ACF, you should use their API to interact with the fields. There's a method called update_field() that does exactly what you are looking for. This method takes 3 parameters:
update_field($field_key, $value, $post_id)
$field_key is an ID ACF gives to each field you create. This image, taken from their very own documentation, shows you how to get it:
Edit: $field_key Will also accept the field name.
$value and $post_id are pretty straight forward, they represent the value you want to set the field with, and the post you are updating.
In your case, you should do something to retrieve this $post_id. Fortunately, that's what wp_insert_post() returns. So, you can do something like this:
$post_information = array(
//'promotion_name' => $_POST['name'],
'post_type' => 'wrestling'
);
$postID = wp_insert_post( $post_information ); //here's the catch
With the ID, then things are easy, just call update_field() for each field you want to update.
update_field('whatever_field_key_for_venue_field', $_POST['venue'], $postID);
update_field('whatever_field_key_for_main_event_field', $_POST['main_event'], $postID);
update_field('whatever_field_key_for_fee_field', $_POST['fee'], $postID);
So basically what you're doing is creating the post first, and then updating it with the values.
I've done this kind of stuff in the functions.php file, and it worked fine. From what I've seen, I think you are using this routine in a template file of some sort. I think it's gonna work fine, you just gotta make sure the ACF plugin is activated.
EDIT:
I forgot the promotion_name field. I commented the line inside $post_information, as it's not going to work. You should use update_field() instead, just like the other 3.
update_field('whatever_field_key_for_promotion_name_field', $_POST['name'], $postID);
There is a way to add custom fields data directly when creating a post. It is mentioned in the wp_insert_post() docs. Just pass an array with custom field keys and values to meta_input like this:
wp_insert_post([
'post_status' => 'publish',
'post_type' => 'wrestling',
'meta_input' => [
'my_custom_field_1' => 'beep',
'my_custom_field_2' => 'boop',
]
]);
I'm looking into this approach to avoid a dozen of update_field() database calls and make it less resource intensive, but I have yet to prove this approach actually makes less database calls in the background.
I am trying to create an Issue in JIRA(v6.2.5) through PHP script using JIRA SOAP API.
Code:
$soapClient = new SoapClient("http://jira.xxx.com/jira/rpc/soap/jirasoapservice-v2?wsdl");
$token = $soapClient->login('username', 'passwd') or die('Username/Password is not correct!');
$issue = array(
'type' => 2,
'priority' => 3,
'project' => 'TEST',
'versions' => 'TEST',
'summary' => 'Doing POC',
"components" => array("id" => "10010"),
'assignee' => 'samj1'
);
$soapClient->createIssue($token, $issue);
Output :
Isssue is created in JIRA but with having few fields Not all.
Fields Type Description
------ -------- -------------
type select single selection dropdown for issue type
priority select single selection dropdown for priority
project Text Field Specific project name
versions select Multiselect dropdown for affected version
assignee select single selection dropdown for assignee
summary text Text field to give the summary
components select Multiselect dropdown for components
Issues I faced:
Except versions and components (muliselect fields), other fields are getting populated while creating the issue trough script.
So could anybody please guide me in solving this issue?
Thanks in advance.
Im a TOTAL newbie to drupal development so please help me here, ok i have created a custom module which so far creates a custom database how do i go about creating a list page in the backend that i can use to manage each item in the DB and how do i go about creating a custom edit form to manage the insert/ edit / delete of each item
function rollover_res_schema() {
$rollover_res = array();
$rollover_res['rollover_res'] = array(
// Example (partial) specification for table "node".
'description' => 'Positioning for rollovers',
'fields' => array(
'rollover_res_id' => array(
'description' => 'The primary identifier for a node.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'rollover_res_actual' => array(
'description' => 'The main rollover plain text.',
'type' => 'text',
'length' => 255,
'not null' => TRUE,
),
),
'indexes' => array(
'rollover_res_id' => array('rollover_res_id'),
),
'primary key' => array('rollover_res_id'),
);
return $rollover_res;
}
If you're a total newbie to Drupal development you should not be writing ANY code for the first month or two and you shouldn't do custom database code the first 6 months.
Start with learning about Fields and Views and once you grasp these you can add one of Display Suite, Context or Panels.
The key to learning how to do things in drupal is:
1) google search how
2) see how other modules do it. In this case, look at some core modules, such as the block module. In there you'll see the schema in .install, and you'll see some functions that create forms for saving new blocks, such as block_add_block_form. You'll need to read up on the form API. But basically, you'll create a form hook to display a form, a menu hook to create a page to hold the form, and a hook to submit the form. If you grep through your code base, you'll see many of examples that you can copy. In fact, there are drupal example modules you can download that cover most of the basics: https://www.drupal.org/project/examples
But to learn how to interact with the database, you could find a module that does something similar to what you're doing and look at how it uses hook_menu to set up page callbacks, forms for editing data.