icon_html = ''; //Call the parent constructor with the required arguments. parent::__construct( // The unique id for your widget. 'apt_wc_cart_icon', // The name of the widget for display purposes. __('APT woocommerce cart icon', 'apt-news'), // The $widget_options array, which is passed through to WP_Widget. // It has a couple of extras like the optional help URL, which should link to your sites help or support page. array( 'description' => __('Display cart icon and count your items in cart', 'apt-news'), 'help' => 'http://seedthemes.com/hello-world-widget-docs', 'panels_groups' => array('apt_widgets'), ), //The $control_options array, which is passed through to WP_Widget array( ), //The $form_options array, which describes the form fields used to configure SiteOrigin widgets. We'll explain these in more detail later. array( 'icon' => array( 'type' => 'icon', 'label' => __('Icon', 'apt-news'), 'default' => 'genericons-cart', ), $this->get_media_query_id() => $this->get_media_query_options(), ), //The $base_folder path string. plugin_dir_path(__FILE__) ); // Add filter to let woo commerce update count in cart icon via ajax add_filter( 'woocommerce_add_to_cart_fragments', array($this, 'apt_wc_cart_icon_ajax_update')); } public function apt_wc_cart_icon_ajax_update( $fragments ) { ob_start(); $this->apt_wc_cart_icon_show_count(); $fragments[ '.item-count' ] = ob_get_clean(); return $fragments; } public function apt_wc_cart_icon_show_count() { if(function_exists('WC')) { ?> cart->get_cart_contents_count() ); ?> instance = $instance; return 'template'; } /* Get less file */ function get_style_name($instance) { return 'style'; } /* set less variable */ function get_less_variables($instance){ return array( ); } } // siteorigin_widget_register($desired_widget_id, $path_to_widget, $class_used_to_create_widget) siteorigin_widget_register('apt_wc_cart_icon', __FILE__, 'APT_Wc_Cart_Icon');