get_price());?>
= -1){ if(is_user_logged_in()){ $user_id = get_current_user_id(); $limit = get_user_meta( $user_id, '_product_per_page', true ); if(!$limit){ add_user_meta( $user_id, '_product_per_page', $products_max); }else{ update_user_meta( $user_id, '_product_per_page', $products_max, $limit); } } $woocommerce->session->ariana_product_per_page = $products_max; return $products_max; } } // load product limit from user meta if(is_user_logged_in() && !isset($woocommerce->session->ariana_product_per_page)){ $user_id = get_current_user_id(); $limit = get_user_meta( $user_id, '_product_per_page', true ); if(array_key_exists($limit, $options)){ $woocommerce->session->ariana_product_per_page = $limit; return $limit; } } // load product limit from session if(isset($woocommerce->session->ariana_product_per_page)){ // set products per page from woo session $products_max = intval($woocommerce->session->ariana_product_per_page); if($products_max != 0 && $products_max >= -1){ return $products_max; } } return $count; } add_filter('loop_shop_per_page','ariana_prodcut_per_page'); /** * Fetch list of avaliable options * @return array */ function ariana_prodcut_per_page_options(){ $options = apply_filters( 'ariana_prodcut_per_page', array( 4 => esc_html__('4', 'ariana'), 8 => esc_html__('8', 'ariana'), 12 => esc_html__('12', 'ariana'), 24 => esc_html__('24', 'ariana'), 48 => esc_html__('48', 'ariana'), 96 => esc_html__('96', 'ariana') )); return $options; } /** * Display dropdown form to change amount of products displayed * @return void */ function ariana_woocommerce_products_per_page(){ $options = ariana_prodcut_per_page_options(); $current_value = ariana_prodcut_per_page(); ?>
get_price());?>
: cart->get_cart_total();?>
get_price());?>
: cart->get_cart_total();?>
Availability: ' . esc_html( $availability['availability'] ). '
'; }else{ $html = ''; } return $html; } add_filter( 'woocommerce_stock_html', 'ariana_stock_availability', 10, 3 ); /** * compare button modify */ if( class_exists( 'YITH_Woocompare_Frontend' ) ) { class ariana_ComBtn extends YITH_Woocompare_Frontend{ public function enqueue_scripts() { // scripts wp_enqueue_script( 'yith-woocompare-main', YITH_WOOCOMPARE_ASSETS_URL . '/js/woocompare.js', array('jquery'), $this->version, true ); wp_localize_script( 'yith-woocompare-main', 'yith_woocompare', array( 'ajaxurl' => WC_AJAX::get_endpoint( "%%endpoint%%" ), 'actionadd' => $this->action_add, 'actionremove' => $this->action_remove, 'actionview' => $this->action_view, 'added_label' => '', 'table_title' => esc_html__( 'Product Comparison', 'ariana' ), 'auto_open' => get_option( 'yith_woocompare_auto_open', 'yes' ), 'loader' => YITH_WOOCOMPARE_ASSETS_URL . '/images/loader.gif', 'button_text' => get_option('yith_woocompare_button_text') )); // colorbox wp_enqueue_style( 'jquery-colorbox', YITH_WOOCOMPARE_ASSETS_URL . '/css/colorbox.css' ); wp_enqueue_script( 'jquery-colorbox', YITH_WOOCOMPARE_ASSETS_URL . '/js/jquery.colorbox-min.js', array('jquery'), '1.4.21', true ); // widget if ( is_active_widget( false, false, 'yith-woocompare-widget', true ) && ! is_admin() ) { wp_enqueue_style( 'yith-woocompare-widget', YITH_WOOCOMPARE_ASSETS_URL . '/css/widget.css' ); } } /** * Add the link to compare */ public function add_compare_link( $product_id = false, $args = array() ) { extract( $args ); if ( ! $product_id ) { global $product; $product_id = isset( $product->id ) ? $product->id : 0; } // return if product doesn't exist if ( empty( $product_id ) || apply_filters( 'yith_woocompare_remove_compare_link_by_cat', false, $product_id ) ) return; $is_button = ! isset( $button_or_link ) || ! $button_or_link ? get_option( 'yith_woocompare_is_button' ) : $button_or_link; if ( ! isset( $button_text ) || $button_text == 'default' ) { $button_text = get_option( 'yith_woocompare_button_text', esc_html__( 'Compare', 'ariana' ) ); yit_wpml_register_string( 'Plugins', 'plugin_yit_compare_button_text', $button_text ); $button_text = yit_wpml_string_translate( 'Plugins', 'plugin_yit_compare_button_text', $button_text ); $button_text = ''; } printf( '%s', $this->add_product_url( $product_id ), 'compare scom' . ( $is_button == 'button' ? ' button' : '' ), $product_id, $button_text ); } /** * Show the html for the shortcode */ public function compare_button_sc( $atts, $content = null ) { $atts = shortcode_atts(array( 'product' => false, 'type' => 'default', 'container' => 'yes' ), $atts); $product_id = 0; /** * Retrieve the product ID in these steps: * - If "product" attribute is not set, get the product ID of current product loop * - If "product" contains ID, post slug or post title */ if ( ! $atts['product'] ) { global $product; $product_id = isset( $product->id ) ? $product->id : 0; } else { global $wpdb; $product = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE ID = %d OR post_name = %s OR post_title = %s LIMIT 1", $atts['product'], $atts['product'], $atts['product'] ) ); if ( ! empty( $product ) ) { $product_id = $product->ID; } } // if product ID is 0, maybe the product doesn't exists or is wrong.. in this case, doesn't show the button if ( empty( $product_id ) ) return; ob_start(); if ( $atts['container'] == 'yes' ) echo ''; return ob_get_clean(); } } new ariana_ComBtn(); }