public function XquantityStockItem::getQuantityWidgetSettings in Commerce Extended Quantity 8
1 call to XquantityStockItem::getQuantityWidgetSettings()
- XquantityStockItem::fieldSettingsForm in modules/
xquantity_stock/ src/ Plugin/ Field/ FieldType/ XquantityStockItem.php
File
- modules/
xquantity_stock/ src/ Plugin/ Field/ FieldType/ XquantityStockItem.php, line 67
Class
- XquantityStockItem
- Defines the 'xquantity_stock' field type.
Namespace
Drupal\xquantity_stock\Plugin\Field\FieldTypeCode
public function getQuantityWidgetSettings() {
$settings = [];
// If 'Add to cart' form display mode is enabled we prefer its settings
// because exactly those settings are exposed to and used by a customer.
$type_id = $this
->getEntity()
->getOrderItemTypeId();
$form_display = \Drupal::entityTypeManager()
->getStorage('entity_form_display');
$form_display_mode = $form_display
->load("commerce_order_item.{$type_id}.add_to_cart");
$quantity = $form_display_mode ? $form_display_mode
->getComponent('quantity') : NULL;
if (!$quantity) {
$form_display_mode = $form_display
->load("commerce_order_item.{$type_id}.default");
$quantity = $form_display_mode ? $form_display_mode
->getComponent('quantity') : NULL;
}
if (isset($quantity['settings']['step'])) {
$settings = $form_display_mode
->getRenderer('quantity')
->getFormDisplayModeSettings();
}
return $settings + $this
->getSettings();
}