| @@ -76,21 +76,54 @@ | ||
| 76 | 76 | { |
| 77 | 77 | $menu = [ |
| 78 | 78 | 'label' => __('Products', 'fluent-cart'), |
| 79 | 79 | 'link' => $baseUrl . 'products', |
| 80 | + // Any-of: a reviews-only role (reviews/manage without | |
| 81 | + // products/view) must still see the parent, or its authorized | |
| 82 | + // Reviews child could never render. Children gate individually — | |
| 83 | + // including on the reviews module being switched on at all. | |
| 84 | + 'permission' => ['products/view', 'reviews/manage'] | |
| 85 | + ]; | |
| 86 | + | |
| 87 | + $children = []; | |
| 88 | + | |
| 89 | + // The parent link is not reachable on touch (the tap opens the dropdown), | |
| 90 | + // and the off-canvas menu renders children only — so list it as a child too. | |
| 91 | + $children['all_products'] = [ | |
| 92 | + 'label' => __('All Products', 'fluent-cart'), | |
| 93 | + 'link' => $baseUrl . 'products', | |
| 80 | 94 | 'permission' => ['products/view'] |
| 81 | 95 | ]; |
| 82 | 96 | |
| 97 | + // Attributes power the advanced-variations feature. | |
| 98 | + $children['product_attributes'] = [ | |
| 99 | + 'label' => __('Attributes', 'fluent-cart'), | |
| 100 | + 'link' => $baseUrl . 'products/attributes', | |
| 101 | + 'permission' => ['products/view'] | |
| 102 | + ]; | |
| 103 | + | |
| 104 | + // Inventory only when the advanced-inventory toggle is on. | |
| 83 | 105 | if (ModuleSettings::isActive('stock_management') && |
| 84 | 106 | ModuleSettings::getSettings('stock_management.enable_advanced_inventory') === 'yes') { |
| 85 | - $menu['children'] = [ | |
| 86 | - 'product_inventory' => [ | |
| 87 | - 'label' => __('Inventory', 'fluent-cart'), | |
| 88 | - 'link' => $baseUrl . 'products/inventory', | |
| 89 | - 'permission' => ['products/view'] | |
| 90 | - ] | |
| 107 | + $children['product_inventory'] = [ | |
| 108 | + 'label' => __('Inventory', 'fluent-cart'), | |
| 109 | + 'link' => $baseUrl . 'products/inventory', | |
| 110 | + 'permission' => ['products/view'] | |
| 91 | 111 | ]; |
| 92 | 112 | } |
| 113 | + | |
| 114 | + // Only while the store has reviews switched on. The screen behind it | |
| 115 | + // already redirects to the dashboard when the module is off, so an | |
| 116 | + // entry here would be a menu item that bounces whoever clicks it. | |
| 117 | + if (ModuleSettings::isActive('reviews')) { | |
| 118 | + $children['reviews'] = [ | |
| 119 | + 'label' => __('Reviews', 'fluent-cart'), | |
| 120 | + 'link' => $baseUrl . 'reviews', | |
| 121 | + 'permission' => ['reviews/manage'] | |
| 122 | + ]; | |
| 123 | + } | |
| 124 | + | |
| 125 | + $menu['children'] = $children; | |
| 93 | 126 | |
| 94 | 127 | return $menu; |
| 95 | 128 | } |
| 96 | 129 | |