| @@ -1,99 +1,93 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace UltimateStoreKit\Modules\MiniCart; | |
| 4 | - | |
| 5 | -use UltimateStoreKit\Base\Ultimate_Store_Kit_Module_Base; | |
| 6 | -use UltimateStoreKit\Modules\MiniCart\Templates\Cart; | |
| 7 | - | |
| 8 | - | |
| 9 | -if (!defined('ABSPATH')) exit; // Exit if accessed directly | |
| 10 | - | |
| 11 | -class Module extends Ultimate_Store_Kit_Module_Base { | |
| 12 | - | |
| 13 | - | |
| 14 | - const TEMPLATE_MINI_CART = 'cart/mini-cart.php'; | |
| 15 | - const OPTION_NAME_USE_MINI_CART = 'use_mini_cart_template'; | |
| 16 | - | |
| 17 | - | |
| 18 | - public function __construct() { | |
| 19 | - | |
| 20 | - parent::__construct(); | |
| 21 | - | |
| 22 | - // if ( ! empty( $_REQUEST['action'] ) && 'elementor' === $_REQUEST['action'] && is_admin() ) { | |
| 23 | - // add_action( 'init', [ $this, 'register_wc_hooks' ], 5 ); | |
| 24 | - // } | |
| 25 | - | |
| 26 | - add_filter('woocommerce_add_to_cart_fragments', [$this, 'ultimate_store_kit_mini_cart_fragment']); | |
| 27 | - add_filter('woocommerce_locate_template', [$this, 'woocommerce_locate_template'], 12, 3); | |
| 28 | - // add_action('wp_footer', [$this, 'render_markup']); | |
| 29 | - } | |
| 30 | - | |
| 31 | - public function render_markup() { | |
| 32 | -?> | |
| 33 | - <div class="toolset"> | |
| 34 | - <div class="ts-container"> | |
| 35 | - <div class="ts-nav-container"></div> | |
| 36 | - <div class="ts-content-container"> | |
| 37 | - <div id="first" class="ts-content-item"> | |
| 38 | - <div class="widget_shopping_cart_content"></div> | |
| 39 | - </div> | |
| 40 | - </div> | |
| 41 | - </div> | |
| 42 | - </div> | |
| 43 | - <?php | |
| 44 | - } | |
| 45 | - | |
| 46 | - public function get_name() { | |
| 47 | - return 'usk-mini-cart'; | |
| 48 | - } | |
| 49 | - | |
| 50 | - public function get_widgets() { | |
| 51 | - | |
| 52 | - $widgets = ['Mini_Cart']; | |
| 53 | - | |
| 54 | - return $widgets; | |
| 55 | - } | |
| 56 | - | |
| 57 | - public function woocommerce_locate_template($template, $template_name, $template_path) { | |
| 58 | - | |
| 59 | - if (self::TEMPLATE_MINI_CART !== $template_name) { | |
| 60 | - return $template; | |
| 61 | - } | |
| 62 | - | |
| 63 | - $plugin_path = BDTUSK_MODULES_PATH . 'mini-cart/templates/'; | |
| 64 | - | |
| 65 | - if (file_exists($plugin_path . $template_name)) { | |
| 66 | - $template = $plugin_path . $template_name; | |
| 67 | - } | |
| 68 | - | |
| 69 | - return $template; | |
| 70 | - } | |
| 71 | - | |
| 72 | - public function ultimate_store_kit_mini_cart_fragment($fragments) { | |
| 73 | - global $woocommerce; | |
| 74 | - | |
| 75 | - ob_start(); | |
| 76 | - | |
| 77 | - ?> | |
| 78 | - <span class="bdt-mini-cart-inner"> | |
| 79 | - <span class="bdt-cart-button-text"> | |
| 80 | - <span class="bdt-mini-cart-price-amount"> | |
| 81 | - <?php echo WC()->cart->get_cart_subtotal(); ?> | |
| 82 | - </span> | |
| 83 | - </span> | |
| 84 | - <span class="bdt-mini-cart-button-icon"> | |
| 85 | - <span class="bdt-cart-badge"> | |
| 86 | - <?php echo WC()->cart->get_cart_contents_count(); ?> | |
| 87 | - </span> | |
| 88 | - <span class="bdt-cart-icon"> | |
| 89 | - <i class="eicon" aria-hidden="true"></i> | |
| 90 | - </span> | |
| 91 | - </span> | |
| 92 | - </span> | |
| 93 | - | |
| 94 | -<?php | |
| 95 | - $fragments['a.bdt-mini-cart-button .bdt-mini-cart-inner'] = ob_get_clean(); | |
| 96 | - | |
| 97 | - return $fragments; | |
| 98 | - } | |
| 99 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace UltimateStoreKit\Modules\MiniCart; | |
| 4 | + | |
| 5 | +use UltimateStoreKit\Base\Ultimate_Store_Kit_Module_Base; | |
| 6 | + | |
| 7 | +if ( ! defined( 'ABSPATH' ) ) | |
| 8 | + exit; // Exit if accessed directly | |
| 9 | + | |
| 10 | +class Module extends Ultimate_Store_Kit_Module_Base { | |
| 11 | + | |
| 12 | + | |
| 13 | + const TEMPLATE_MINI_CART = 'cart/mini-cart.php'; | |
| 14 | + const OPTION_NAME_USE_MINI_CART = 'use_mini_cart_template'; | |
| 15 | + | |
| 16 | + public function __construct() { | |
| 17 | + | |
| 18 | + parent::__construct(); | |
| 19 | + | |
| 20 | + wp_enqueue_script( 'wc-cart-fragments' ); | |
| 21 | + | |
| 22 | + add_filter( 'woocommerce_add_to_cart_fragments', [ $this, 'ultimate_store_kit_mini_cart_fragment' ] ); | |
| 23 | + add_filter( 'woocommerce_locate_template', [ $this, 'woocommerce_locate_template' ], 12, 3 ); | |
| 24 | + } | |
| 25 | + | |
| 26 | + public function render_markup() { | |
| 27 | + ?> | |
| 28 | + <div class="toolset"> | |
| 29 | + <div class="ts-container"> | |
| 30 | + <div class="ts-nav-container"></div> | |
| 31 | + <div class="ts-content-container"> | |
| 32 | + <div id="first" class="ts-content-item"> | |
| 33 | + <div class="widget_shopping_cart_content"></div> | |
| 34 | + </div> | |
| 35 | + </div> | |
| 36 | + </div> | |
| 37 | + </div> | |
| 38 | + <?php | |
| 39 | + } | |
| 40 | + | |
| 41 | + public function get_name() { | |
| 42 | + return 'usk-mini-cart'; | |
| 43 | + } | |
| 44 | + | |
| 45 | + public function get_widgets() { | |
| 46 | + | |
| 47 | + $widgets = [ 'Mini_Cart' ]; | |
| 48 | + | |
| 49 | + return $widgets; | |
| 50 | + } | |
| 51 | + | |
| 52 | + public function woocommerce_locate_template( $template, $template_name, $template_path ) { | |
| 53 | + | |
| 54 | + if ( self::TEMPLATE_MINI_CART !== $template_name ) { | |
| 55 | + return $template; | |
| 56 | + } | |
| 57 | + | |
| 58 | + $plugin_path = BDTUSK_MODULES_PATH . 'mini-cart/templates/'; | |
| 59 | + | |
| 60 | + if ( file_exists( $plugin_path . $template_name ) ) { | |
| 61 | + $template = $plugin_path . $template_name; | |
| 62 | + } | |
| 63 | + | |
| 64 | + return $template; | |
| 65 | + } | |
| 66 | + | |
| 67 | + public function ultimate_store_kit_mini_cart_fragment( $fragments ) { | |
| 68 | + global $woocommerce; | |
| 69 | + | |
| 70 | + ob_start(); | |
| 71 | + | |
| 72 | + ?> | |
| 73 | + <span class="usk-mini-cart-inner"> | |
| 74 | + <span class="usk-cart-button-text"> | |
| 75 | + <span class="usk-mini-cart-price-amount"> | |
| 76 | + <?php echo wp_kses_post( WC()->cart->get_cart_subtotal() ); ?> | |
| 77 | + </span> | |
| 78 | + </span> | |
| 79 | + <span class="usk-mini-cart-button-icon"> | |
| 80 | + <span class="usk-cart-badge"> | |
| 81 | + <?php echo wp_kses_post( WC()->cart->get_cart_contents_count() ); ?> | |
| 82 | + </span> | |
| 83 | + <span class="usk-cart-icon"> | |
| 84 | + <i class="usk-icon-cart" aria-hidden="true"></i> | |
| 85 | + </span> | |
| 86 | + </span> | |
| 87 | + </span> | |
| 88 | + <?php | |
| 89 | + $fragments['div.usk-mini-cart-toggle-btn .usk-mini-cart-inner'] = ob_get_clean(); | |
| 90 | + | |
| 91 | + return $fragments; | |
| 92 | + } | |
| 93 | +} | |