cart->get_cart()); $count = ob_get_clean(); // Get mini cart ob_start(); woocommerce_mini_cart(); $mini_cart = ob_get_clean(); $fragments ['.dt-sc-shop-cart-widget-header'] = '

'.esc_html__( 'Shopping cart', 'alagu' ).' '.esc_html($count).' '.esc_html__( 'Close', 'alagu' ).'

'; $fragments ['.dt-sc-shop-cart-widget-content'] = '
'.alagu_html_output($mini_cart).'
'; } if($addtocart_custom_action == 'notification_widget') { global $woocommerce; $items = $woocommerce->cart->get_cart(); $ids = array(); foreach($items as $item => $values) { $_product = $values['data']->post; $ids[] = $_product->ID; } $last_product_id = end($ids); $product = wc_get_product( $last_product_id ); $fragments ['.dt-sc-shop-cart-widget-header'] = '
'.esc_html__( 'Close', 'alagu' ).'
'; $fragments ['.dt-sc-shop-cart-widget-content'] = '
'.alagu_html_output($product->get_image()).'
'.sprintf( esc_html__( 'Product %1$s has been added to cart sucessfully.', 'alagu' ), ''.alagu_html_output($product->get_name()).'').'
'; } // Shortcode // Total items in cart $count = count(WC()->cart->get_cart()); // Total items in cart $subtotal = WC()->cart->get_cart_subtotal(); // Get mini cart ob_start(); woocommerce_mini_cart(); $mini_cart = ob_get_clean(); $fragments ['.dt-sc-shop-menu-cart-number'] = ''.alagu_html_output($count).''; $fragments ['.dt-sc-shop-menu-cart-subtotal'] = ''.alagu_html_output($subtotal).''; $fragments ['.dt-sc-shop-menu-cart-totals'] = ''.alagu_html_output($subtotal).''; $fragments ['.dt-sc-shop-menu-cart-content'] = '
'.alagu_html_output($mini_cart).'
'; return $fragments; } add_filter('woocommerce_add_to_cart_fragments', 'alagu_woo_cart_fragments'); } if ( ! function_exists( 'alagu_woo_sidebar_widget' ) ) { function alagu_woo_sidebar_widget() { $addtocart_custom_action = alagu_get_option( 'dt-woo-addtocart-custom-action' ); $addtocart_custom_action = (isset($addtocart_custom_action) && $addtocart_custom_action != '') ? $addtocart_custom_action : ''; $notification_class = ''; if($addtocart_custom_action == 'notification_widget') { $notification_class = 'cart-notification-widget'; } else if($addtocart_custom_action == 'sidebar_widget') { $notification_class = 'activate-sidebar-widget'; } else { if ( $cart_action = get_site_transient( 'cart_action' ) ) { if($cart_action == 'sidebar_widget') { $notification_class = 'activate-sidebar-widget'; } } } if($notification_class != '') { echo '
'; echo '
'; echo '
'; echo '

'.esc_html__( 'Your Shopping cart', 'alagu' ).'

'; echo ''.esc_html__( 'Close', 'alagu' ).''; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; } } add_action( 'wp_footer', 'alagu_woo_sidebar_widget', 10 ); } ?>