. * */ /* Name: Catalog mode Slug: catalog-mode Category: tools Url: https://www.vvveb.com Description: Hide add to cart and checkout and cart pages. Author: givanz Version: 0.1 Thumb: catalog-mode.svg Author url: https://www.vvveb.com */ use Vvveb\System\Event; if (! defined('V_VERSION')) { die('Invalid request!'); } class CatalogModePlugin { function admin() { } function app() { $ecommerceRoutes = [ //ecommerce //checkout '/cart', '/cart/add/#product_id#', '/cart/remove/#product_id#', '/cart/voucher', '/checkout/#product_id#', '/checkout', '/checkout/pay', '/checkout/confirm', '/checkout/confirm/#id#', ]; //remove ecommerce cart and checkout pages Event::on('Vvveb\System\Routes', 'init', __CLASS__, function ($routes) use ($ecommerceRoutes) { foreach ($ecommerceRoutes as $route) { unset($routes[$route]); } return [$routes]; }); } function __construct() { if (APP == 'admin') { $this->admin(); } else { if (APP == 'app') { $this->app(); } } Event::on('Vvveb\System\Core\View', 'compile:after', __CLASS__, function ($template, $htmlFile, $tplFile, $vTpl, $view) { //remove ecommerce components from html //if ($url = Routes::getUrlData()) { //if (in_array($url['route'], $routes)) { $vTpl->loadTemplateFile(__DIR__ . '/app/template/common.tpl'); //} //} return [$template, $htmlFile, $tplFile, $vTpl, $view]; }); } } $hideEcommercePlugin = new CatalogModePlugin();