public function ProductAdjustmentsForm::submitForm in Ubercart 8.4
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- uc_attribute/
src/ Form/ ProductAdjustmentsForm.php, line 172
Class
- ProductAdjustmentsForm
- Associates option combinations with a product variant's SKU.
Namespace
Drupal\uc_attribute\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
foreach ($form_state
->getValue('body') as $value) {
if (!empty($value['model']) && $value['model'] != $form_state
->getValue('default')) {
\Drupal::database()
->merge('uc_product_adjustments')
->key([
'nid' => $form_state
->getValue('nid'),
'combination' => $value['combo_array'],
])
->fields([
'model' => $value['model'],
])
->execute();
}
else {
\Drupal::database()
->delete('uc_product_adjustments')
->condition('nid', $form_state
->getValue('nid'))
->condition('combination', $value['combo_array'])
->execute();
}
}
$this
->messenger()
->addMessage($this
->t('Product adjustments have been saved.'));
}