Elements admin tab (plugin/admin/settings-page/tabs/ * elements.php) already lets a site owner hide any element from the builder's Add panel * via the `breakdance_builder_elements` filter and Breakdance\Elements\FilteredGets\ * addPanelRules()'s `alwaysHide` flag; that function's own comment records exactly the * property this task needs: "Hidden elements will not appear in the Add panel, but * existing instances in designs remain functional." This element is NOT force-hidden * from here, though: that switch is presented as the SITE OWNER's own opt-in choice (it * is a per-site admin setting, `builder_hidden_elements`), and given point (3) above, * hiding it outright would remove a still-legitimate choice, not just an accidental one. * A site owner who wants it gone from the Add panel entirely already can, with no code * change, via that existing Breakdance setting. What this element's OWN registration can * and does change is name()/badge(), the two fields the Add panel and the layers/outline * panel both render, so an editor sees it is the legacy option before picking it, on * every page that already places it too. slug() and className() are untouched, on * purpose: they are this element's saved-tree identity, and changing either would break * every already-placed instance. */ final class MiniCart extends \Breakdance\Elements\Element { public static function uiIcon() { return ''; } public static function tag() { return 'div'; } public static function tagOptions() { return []; } public static function tagControlPath() { return false; } public static function name() { return 'Mini Cart (Legacy)'; } public static function className() { return 'fcbd-mini-cart-element'; } public static function category() { return 'fluentcart'; } public static function badge() { return ['label' => 'Legacy', 'backgroundColor' => '#9ca3af', 'textColor' => '#1f2937']; } public static function slug() { return __CLASS__; } public static function template() { return file_get_contents(__DIR__ . '/html.twig'); } public static function defaultCss() { return file_get_contents(__DIR__ . '/default.css'); } public static function cssTemplate() { return file_get_contents(__DIR__ . '/css.twig'); } public static function defaultChildren() { return false; } public static function dependencies() { return \FluentCartBreakdance\Compatibility\AssetManager::miniCartDependencies(); } public static function settingsControls() { return []; } public static function settings() { return ['proOnly' => false]; } public static function availableIn() { return ['oxygen', 'breakdance']; } public static function propertyPathsToSsrElementWhenValueChanges() { return ['content.cart']; } public static function defaultProperties() { return ['content' => ['cart' => [ 'cart_icon' => 'bag', 'show_item_count' => 'has_items', 'show_total_price' => true, 'count_mode' => 'distinct_products', ]]]; } public static function contentControls() { return [c('cart', __('Mini cart', 'sparkcore-commerce'), [ c('cart_icon', __('Icon', 'sparkcore-commerce'), [], ['type' => 'dropdown', 'layout' => 'inline', 'items' => [ ['value' => 'cart', 'text' => __('Cart', 'sparkcore-commerce')], ['value' => 'bag', 'text' => __('Bag', 'sparkcore-commerce')], ['value' => 'bag-alt', 'text' => __('Bag outline', 'sparkcore-commerce')], ]], false, false, []), c('show_item_count', __('Item count', 'sparkcore-commerce'), [], ['type' => 'dropdown', 'layout' => 'inline', 'items' => [ ['value' => 'always', 'text' => __('Always', 'sparkcore-commerce')], ['value' => 'has_items', 'text' => __('When populated', 'sparkcore-commerce')], ['value' => 'never', 'text' => __('Never', 'sparkcore-commerce')], ]], false, false, []), c('show_total_price', __('Show total price', 'sparkcore-commerce'), [], ['type' => 'toggle', 'layout' => 'inline'], false, false, []), c('count_mode', __('Count', 'sparkcore-commerce'), [], ['type' => 'dropdown', 'layout' => 'inline', 'items' => [ ['value' => 'distinct_products', 'text' => __('Distinct products', 'sparkcore-commerce')], ['value' => 'total_quantity', 'text' => __('Total quantity', 'sparkcore-commerce')], ]], false, false, []), ], ['type' => 'section', 'layout' => 'vertical'], false, false, [])]; } public static function designControls() { return [controlSection('button', __('Trigger', 'sparkcore-commerce'), [ control('color', __('Color', 'sparkcore-commerce'), ['type' => 'color', 'layout' => 'inline']), control('background', __('Background', 'sparkcore-commerce'), ['type' => 'color', 'layout' => 'inline']), control('size', __('Icon size', 'sparkcore-commerce'), ['type' => 'unit', 'layout' => 'inline']), control('padding', __('Padding', 'sparkcore-commerce'), ['type' => 'unit', 'layout' => 'inline']), control('radius', __('Radius', 'sparkcore-commerce'), ['type' => 'unit', 'layout' => 'inline']), ])]; } }