Automattic\WooCommerce\Internal\POS
Capabilities::preset_definitions
Preset metadata: the woocommerce_pos_* cap bundle and display label for each preset.
Single source of truth for capabilities_for_preset() and preset_label(), so adding or renaming a preset is one edit here (plus the POSPreset constant) rather than several parallel switches.
Capability Cashier Manager Admin woocommerce_pos_process_sales yes yes yes woocommerce_pos_view_orders yes yes yes woocommerce_pos_apply_coupons yes yes yes woocommerce_pos_create_coupons no yes yes woocommerce_pos_issue_refunds no yes yes woocommerce_pos_view_settings no yes yes woocommerce_pos_edit_settings no no yes woocommerce_pos_manage_staff no no yes woocommerce_pos_exit no no yes
Method of the class: Capabilities{}
No Hooks.
Returns
array<string,. array{caps: array<string, true>, label: string}>
Usage
$result = Capabilities::preset_definitions(): array;
Capabilities::preset_definitions() Capabilities::preset definitions code WC 11.1.2
private static function preset_definitions(): array {
$cashier_caps = array(
self::CAP_PROCESS_SALES => true,
self::CAP_VIEW_ORDERS => true,
self::CAP_APPLY_COUPONS => true,
);
$manager_caps = $cashier_caps + array(
self::CAP_CREATE_COUPONS => true,
self::CAP_ISSUE_REFUNDS => true,
self::CAP_VIEW_SETTINGS => true,
);
$admin_caps = $manager_caps + array(
self::CAP_EDIT_SETTINGS => true,
self::CAP_MANAGE_STAFF => true,
self::CAP_EXIT_POS => true,
);
return array(
POSPreset::CASHIER => array(
'caps' => $cashier_caps,
'label' => __( 'POS cashier', 'woocommerce' ),
),
POSPreset::MANAGER => array(
'caps' => $manager_caps,
'label' => __( 'POS manager', 'woocommerce' ),
),
POSPreset::ADMIN => array(
'caps' => $admin_caps,
'label' => __( 'POS admin', 'woocommerce' ),
),
);
}