CTprefix = $al_prefix; //Silence is Pure Gold } //font styles callback public function alanah_fonts_styles() { return "ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900"; } /** * wpdb get_var callback */ public static function wpdb_count( $type ) { global $wpdb, $post; $condition = ''; if( $type == 'COUNT' ) $condition = " AND meta_value > 0"; return $wpdb->get_var(" SELECT ".$type."(meta_value) FROM $wpdb->commentmeta LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID WHERE meta_key = 'rating' AND comment_post_ID = $post->ID AND comment_approved = '1' " . $condition . " "); } /** * Subcategories Query Arguments */ public function subcategories_args( $term_id ) { $args = array( 'taxonomy' => 'product_cat', 'title_li' => '', 'show_count' => 0, 'hide_empty' => false, 'echo' => false, 'show_option_none' => '', 'child_of' => $term_id ); if( get_option( 'show_category_count' ) == 1 ) $args['show_count'] = 1; return $args; } /** * Check if product have 'new' badge active */ public static function alanah_product_is_new( $product_id = '' ) { global $post, $wpdb; $key = '_new_label'; if( !$product_id ) return false; $_new_label = get_post_meta( $product_id, $key, true ); return $_new_label; } /** * Active Product labels */ public static function woo_product_labels( $count ) { global $post, $wpdb, $product; $output = ''; //If Product is in sale. So active Sale badge if ( alanah_get_option( 'sale_icon' ) ) : if ( $product->is_on_sale() ) { $alanah_wrap = ''; $close_wrap = ''; $count++; $output .= $alanah_wrap . '' . __( 'Sale', 'alanah-free' ) . '' . $close_wrap; } endif; //If Product Have new badge active. if( self::alanah_product_is_new( $post->ID ) ) : $alanah_wrap = ''; $close_wrap = ''; $count++; $second_label = ( $count > 1 ) ? 'second_label' : ''; $output .= $alanah_wrap . '' . __( 'New', 'alanah-free' ) . '' . $close_wrap; endif; return $output; } //woo_product_labels /** * Generate random string for token purpose */ public function alanah_random_string( $length = 8 ) { $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomClass = ''; for ($i = 0; $i < $length; $i++) { $randomClass .= $characters[rand(0, $charactersLength - 1)]; } return $randomClass; } /** * jQueries for carousels */ public static function carousel_based_jq( $boxid, $cols, $scroll, $autoplay, $direction ) { echo ''; } /** * Cart single item html. Called statically */ public static function alanah_cart_single_item( $cart_item, $cart_item_key, $product_price ) { $_product = $cart_item['data']; return '
' . get_the_post_thumbnail( $cart_item['product_id'], array( 50, 50 ) ) . ' ' . apply_filters( 'woocommerce_cart_item_remove_link', sprintf('×', esc_url( wc_get_cart_remove_url( $cart_item_key ) ), __( 'Remove this item', 'alanah-free' ) ), $cart_item_key ) . '
' . apply_filters('woocommerce_widget_cart_product_title', $_product->get_title(), $_product ) . '
' . $product_price . ' ( ' . __( 'Quantity', 'alanah-free' ) . ': ' . $cart_item['quantity'] . ' )
'; } /** * Cart Total html. Called statically */ public static function alanah_cart_total() { $output = '
' . __( 'Total:', 'alanah-free' ) . ' ' . WC()->cart->get_cart_subtotal() . '
'; do_action( 'woocommerce_widget_shopping_cart_before_buttons' ); $output .= ' ' . __( 'View Cart →', 'alanah-free' ) . ' ' . __( 'Checkout →', 'alanah-free' ) . ' '; return $output; } } endif; ?>