How can I access the label of the product price field to change it for example to "amount" instead of "price"?
The html for the field is:
<div class="js-form-item form-item js-form-type-commerce-number form-item-variations-entity-price-0-number js-form-item-variations-entity-price-0-number"> <label for="edit-variations-entity-price-0-number" class="js-form-required form-required">Price</label> <input data-drupal-selector="edit-variations-entity-price-0-number" type="text" id="edit-variations-entity-price-0-number" name="variations[entity][price][0][number]" value="" size="10" maxlength="128" class="form-text required" required="required">
I have tried various alternatives, but couldn’t find a way to reach the title or the price field.
function THEME_form_alter(&$form, DrupalCoreFormFormStateInterface $form_state, $form_id) { $form['variations']['entity']['price'][0]['number']= t('Amount'); $form['variations']['entity']['price']['number']= t('Amount'); $form['price']= t('Amount'); }
I also couldn’t find any examples to use form_alter on Drupal 8 Commerce product form while it was possible with Drupal 7.