Skip to content

Commit f4c04e4

Browse files
committed
Issue #2982202 by bojanz: Update promotion offer UX
1 parent 5a48bc0 commit f4c04e4

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

modules/promotion/src/Entity/Promotion.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
618618
]);
619619

620620
$fields['offer'] = BaseFieldDefinition::create('commerce_plugin_item:commerce_promotion_offer')
621-
->setLabel(t('Offer'))
621+
->setLabel(t('Offer type'))
622622
->setCardinality(1)
623623
->setRequired(TRUE)
624624
->setDisplayOptions('form', [

modules/promotion/src/Plugin/Commerce/PromotionOffer/FixedAmountOffTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
3333

3434
$form['amount'] = [
3535
'#type' => 'commerce_price',
36-
'#title' => $this->t('Amount'),
36+
'#title' => $this->t('Amount off'),
3737
'#default_value' => $amount,
3838
'#required' => TRUE,
39+
'#weight' => -1,
3940
];
4041

4142
return $form;

modules/promotion/src/Plugin/Commerce/PromotionOffer/PercentageOffTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,15 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
4040

4141
$form['percentage'] = [
4242
'#type' => 'commerce_number',
43-
'#title' => $this->t('Percentage'),
43+
'#title' => $this->t('Percentage off'),
4444
'#default_value' => Calculator::multiply($this->getPercentage(), '100'),
4545
'#maxlength' => 255,
4646
'#min' => 0,
4747
'#max' => 100,
4848
'#size' => 4,
4949
'#field_suffix' => $this->t('%'),
5050
'#required' => TRUE,
51+
'#weight' => -1,
5152
];
5253

5354
return $form;

modules/promotion/src/Plugin/Commerce/PromotionOffer/PromotionOfferBase.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ public function setConfiguration(array $configuration) {
8686
* {@inheritdoc}
8787
*/
8888
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
89+
// Wrap the offer configuration in a fieldset by default.
90+
$form['#type'] = 'fieldset';
91+
$form['#title'] = $this->t('Offer');
92+
$form['#collapsible'] = FALSE;
93+
8994
return $form;
9095
}
9196

0 commit comments

Comments
 (0)