cart || ! method_exists(WC()->cart, 'get_cart_contents_count') ) { return ''; } if (! isset($device)) { $device = 'desktop'; } if (isset($render_args['device'])) { $device = $render_args['device']; } $has_only_item = false; $has_only_cart = false; $has_only_totals = false; $has_only_count = false; if (isset($render_args['only_item'])) { $has_only_item = $render_args['only_item']; } if (isset($render_args['only_cart'])) { $has_only_cart = $render_args['only_cart']; } if (isset($render_args['only_totals'])) { $has_only_totals = $render_args['only_totals']; } if (isset($render_args['only_count'])) { $has_only_count = $render_args['only_count']; } $has_badge = blocksy_default_akg('has_cart_badge', $atts, 'yes') === 'yes'; $icon = apply_filters('blocksy:header:cart:icons', [ 'type-1' => '', 'type-2' => '', 'type-3' => '', 'type-4' => '', 'type-5' => '', 'type-6' => '', ]); $class = 'ct-header-cart'; $item_visibility = blocksy_default_akg('header_cart_visibility', $atts, [ 'tablet' => true, 'mobile' => true, ]); $class .= ' ' . blocksy_visibility_classes($item_visibility); $has_cart_dropdown = blocksy_default_akg( 'has_cart_dropdown', $atts, 'yes' ) === 'yes'; $cart_drawer_type = blocksy_default_akg('cart_drawer_type', $atts, 'dropdown'); // Force dropdown drawer type if option is not visible. if ( $cart_drawer_type !== 'dropdown' && apply_filters( 'blocksy:header:cart:cart_drawer_type:option', 'hidden' ) === 'hidden' ) { $cart_drawer_type = 'dropdown'; } $cart_total_class = 'ct-label'; $cart_subtotal_visibility = blocksy_default_akg( 'cart_subtotal_visibility', $atts, [ 'desktop' => true, 'tablet' => true, 'mobile' => true, ] ); $cart_total_class .= ' ' . blocksy_visibility_classes($cart_subtotal_visibility); $cart_total_position = blocksy_expand_responsive_value( blocksy_akg('cart_total_position', $atts, 'left') ); $icon_type = blocksy_default_akg('mini_cart_type', $atts, 'type-1'); if (empty($icon_type)) { $icon_type = 'type-1'; } $icon = $icon[$icon_type]; if (function_exists('blc_get_icon')) { $icon_source = blocksy_default_akg('icon_source', $atts, 'default'); if ( $icon_source === 'custom' ) { $icon = blc_get_icon([ 'icon_descriptor' => blocksy_akg('icon', $atts, [ 'icon' => 'blc blc-cart' ]), 'icon_container' => false ]); } } $item_class = 'ct-cart-item'; $url = wc_get_cart_url(); $auto_open_output = ''; if ($has_cart_dropdown && $cart_drawer_type === 'offcanvas') { $item_class .= ' ct-offcanvas-trigger'; $url = '#woo-cart-panel'; $auto_open_cart = blocksy_default_akg('auto_open_cart', $atts, [ 'archive' => false, 'product' => false, ]); $components = []; if ($auto_open_cart['archive']) { $components[] = 'archive'; } if ($auto_open_cart['product']) { $components[] = 'product'; } if (! empty($components)) { $auto_open_output = 'data-auto-open="' . implode(':', $components) . '"'; } } $url = apply_filters('blocksy:header:cart:url', $url); ob_start(); $count_output = ''; $current_count = 0; if (WC()->cart && method_exists(WC()->cart, 'get_cart_contents_count')) { $current_count = WC()->cart->get_cart_contents_count(); } $count_output = blocksy_html_tag( 'span', [ 'class' => 'ct-dynamic-count-cart', 'data-count' => $has_badge ? $current_count : 0, 'aria-hidden' => 'true' ], $current_count ); $totals_output = ''; $label_mask = blocksy_expand_responsive_value( blocksy_default_akg('cart_total_label', $atts, '{price}') )[$device]; $label_parts = explode( '{price}', $label_mask ); if (WC()->cart) { $totals_output = WC()->cart->get_cart_subtotal(); $totals_output = blocksy_html_tag( 'span', [ 'class' => 'ct-amount' ], $totals_output ); } $before_totals = isset($label_parts[0]) ? $label_parts[0] : ''; $after_totals = isset($label_parts[1]) ? $label_parts[1] : ''; $aria_label = __('Shopping cart', 'blocksy'); $label = $before_totals . $totals_output . $after_totals; if ( ! empty($before_totals) || ! empty($after_totals) ) { $aria_label = ''; } $screen_reader_text = ''; if (! empty($aria_label)) { $screen_reader_text = blocksy_html_tag( 'span', [ 'class' => 'screen-reader-text' ], $aria_label ); } ?> > $cart_total_class, 'data-price' => strpos($label_mask, '{price}') !== false ? 'yes' : 'no' ], ), $label ); ?> 'ct-cart-content', 'data-count' => $current_count ], $content ); if ($has_only_cart) { echo $cart_otput; return; } if ($has_only_totals) { echo $totals_output; return; } if ($has_only_count) { echo $count_output; return; } ?>