Skip to content

Commit

Permalink
Issue #2982202 by bojanz: Update promotion offer UX
Browse files Browse the repository at this point in the history
  • Loading branch information
bojanz committed Jun 27, 2018
1 parent 5a48bc0 commit f4c04e4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion modules/promotion/src/Entity/Promotion.php
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
]);

$fields['offer'] = BaseFieldDefinition::create('commerce_plugin_item:commerce_promotion_offer')
->setLabel(t('Offer'))
->setLabel(t('Offer type'))
->setCardinality(1)
->setRequired(TRUE)
->setDisplayOptions('form', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta

$form['amount'] = [
'#type' => 'commerce_price',
'#title' => $this->t('Amount'),
'#title' => $this->t('Amount off'),
'#default_value' => $amount,
'#required' => TRUE,
'#weight' => -1,
];

return $form;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta

$form['percentage'] = [
'#type' => 'commerce_number',
'#title' => $this->t('Percentage'),
'#title' => $this->t('Percentage off'),
'#default_value' => Calculator::multiply($this->getPercentage(), '100'),
'#maxlength' => 255,
'#min' => 0,
'#max' => 100,
'#size' => 4,
'#field_suffix' => $this->t('%'),
'#required' => TRUE,
'#weight' => -1,
];

return $form;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ public function setConfiguration(array $configuration) {
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
// Wrap the offer configuration in a fieldset by default.
$form['#type'] = 'fieldset';
$form['#title'] = $this->t('Offer');
$form['#collapsible'] = FALSE;

return $form;
}

Expand Down

0 comments on commit f4c04e4

Please sign in to comment.