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'] = '
'; $fragments ['.dt-sc-shop-cart-widget-content'] = ''; } 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'] = ''; $fragments ['.dt-sc-shop-cart-widget-content'] = ''; } // 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'] = ''; $fragments ['.dt-sc-shop-menu-cart-subtotal'] = ''; $fragments ['.dt-sc-shop-menu-cart-totals'] = ''; $fragments ['.dt-sc-shop-menu-cart-content'] = ''; 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 ''; } } add_action( 'wp_footer', 'alagu_woo_sidebar_widget', 10 ); } ?>