function commerce_cart_blocks_ajax_settings in Commerce Cart Blocks 8
Get AJAX settings.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity.
Return value
array An array of commerce_cart_blocks_ajax settings
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
1 call to commerce_cart_blocks_ajax_settings()
File
- ./
commerce_cart_blocks.module, line 192 - Contains commerce_cart_blocks.module.
Code
function commerce_cart_blocks_ajax_settings(EntityInterface $entity) {
/** @var \Drupal\commerce_order\Entity\OrderItemTypeInterface $item_type */
$item_type = \Drupal::entityTypeManager()
->getStorage('commerce_order_item_type')
->load($entity
->bundle());
/** @var \Drupal\commerce_order\Entity\OrderTypeInterface $order_type */
$order_type = \Drupal::entityTypeManager()
->getStorage('commerce_order_type')
->load($item_type
->getOrderTypeId());
return [
'enabled' => $order_type
->getThirdPartySetting('commerce_cart_blocks', 'commerce_cart_blocks_ajax', FALSE),
'modal_enabled' => $order_type
->getThirdPartySetting('commerce_cart_blocks', 'commerce_cart_blocks_ajax_modal', TRUE),
'refresh_page_after_modal' => $order_type
->getThirdPartySetting('commerce_cart_blocks', 'commerce_cart_blocks_refresh_page_after_modal', FALSE),
'cart' => $order_type
->getThirdPartySetting('commerce_cart_blocks', 'commerce_cart_blocks_add_cart', FALSE),
'checkout' => $order_type
->getThirdPartySetting('commerce_cart_blocks', 'commerce_cart_blocks_add_checkout', FALSE),
'keep_browsing' => $order_type
->getThirdPartySetting('commerce_cart_blocks', 'commerce_cart_blocks_add_keep_browsing', FALSE),
'modal_title' => $order_type
->getThirdPartySetting('commerce_cart_blocks', 'commerce_cart_blocks_ajax_modal_title', 'Cart'),
'append_block_id' => $order_type
->getThirdPartySetting('commerce_cart_blocks', 'commerce_cart_blocks_append_block_id', ''),
];
}