plugin_url() . '/assets/fonts/';
$inline_font = '@font-face {
font-family: "star";
src: url("' . $font_path . 'star.eot");
src: url("' . $font_path . 'star.eot?#iefix") format("embedded-opentype"),
url("' . $font_path . 'star.woff") format("woff"),
url("' . $font_path . 'star.ttf") format("truetype"),
url("' . $font_path . 'star.svg#star") format("svg");
font-weight: normal;
font-style: normal;
}';
wp_add_inline_style( 'onlineestore-woocommerce-style', $inline_font );
}
//add_action( 'wp_enqueue_scripts', 'online_estore_woocommerce_scripts' );
/**
* Disable the default WooCommerce stylesheet.
*
* Removing the default WooCommerce stylesheet and enqueing your own will
* protect you during WooCommerce core updates.
*
* @link https://docs.woocommerce.com/document/disable-the-default-stylesheet/
*/
//add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );
/**
* Add 'woocommerce-active' class to the body tag.
*
* @param array $classes CSS classes applied to the body tag.
* @return array $classes modified to include 'woocommerce-active' class.
*/
function online_estore_woocommerce_active_body_class( $classes ) {
$classes[] = 'woocommerce-active';
return $classes;
}
add_filter( 'body_class', 'online_estore_woocommerce_active_body_class' );
/**
* Products per page.
*
* @return integer number of products.
*/
function online_estore_woocommerce_products_per_page() {
return get_theme_mod( 'online_estore_display_number_products', 12 );
}
add_filter( 'loop_shop_per_page', 'online_estore_woocommerce_products_per_page' );
/**
* Default loop columns on product archives.
*
* @return integer products per row.
*/
function online_estore_woocommerce_loop_columns() {
return get_theme_mod( 'online_estore_enter_display_number_columns', 3 );
}
add_filter( 'loop_shop_columns', 'online_estore_woocommerce_loop_columns' );
/**
* Product gallery thumnbail columns.
*
* @return integer number of columns.
*/
function online_estore_woocommerce_thumbnail_columns() {
return 4;
}
add_filter( 'woocommerce_product_thumbnails_columns', 'online_estore_woocommerce_thumbnail_columns' );
/**
* Related Products Args.
*
* @param array $args related products args.
* @return array $args related products args.
*/
// Change Related Products Text
function online_estore_related_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Related products' :
$translated_text = get_theme_mod( 'online_estore_single_related_product_title','Related products' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'online_estore_related_text_strings', 20, 3 );
function online_estore_woocommerce_related_products_args( $args ) {
$related_product_columns = get_theme_mod( 'online_estore_single_num_related_product_columns', 3 );
$display_related_product = get_theme_mod( 'online_estore_single_num_related_product', 6 );
$defaults = array(
'posts_per_page' => $display_related_product,
'columns' => $related_product_columns,
);
$args = wp_parse_args( $defaults, $args );
return $args;
}
add_filter( 'woocommerce_output_related_products_args', 'online_estore_woocommerce_related_products_args' );
/**
* Output product up sells.
*
* @param int $posts_per_page (default: -1)
* @param int $columns (default: 2)
*/
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
if ( ! function_exists( 'online_estore_woocommerce_upsell_display' ) ) {
function online_estore_woocommerce_upsell_display() {
$posts_per_page = get_theme_mod( 'online_estore_single_num_upsells_product', 6 );
$upsells_product_columns = get_theme_mod( 'online_estore_single_num_upsells_product_columns', 3 );
woocommerce_upsell_display( $posts_per_page, $upsells_product_columns );
}
}
add_action( 'woocommerce_after_single_product_summary', 'online_estore_woocommerce_upsell_display', 15 );
if ( ! function_exists( 'online_estore_woocommerce_product_columns_wrapper' ) ) {
/**
* Product columns wrapper.
*
* @return void
*/
function online_estore_woocommerce_product_columns_wrapper() {
$columns = online_estore_woocommerce_loop_columns();
echo '
';
}
}
add_action( 'woocommerce_before_shop_loop', 'online_estore_woocommerce_product_columns_wrapper', 40 );
if ( ! function_exists( 'online_estore_woocommerce_product_columns_wrapper_close' ) ) {
/**
* Product columns wrapper close.
*
* @return void
*/
function online_estore_woocommerce_product_columns_wrapper_close() {
echo '
';
}
}
add_action( 'woocommerce_after_shop_loop', 'online_estore_woocommerce_product_columns_wrapper_close', 8 );
/**
* Descriptions on Header Menu
* @author Sparkle Themes
* @param string $item_output , HTML outputp for the menu item
* @param object $item , menu item object
* @param int $depth , depth in menu structure
* @param object $args , arguments passed to wp_nav_menu()
* @return string $item_output
*/
function online_estore_header_menu_desc($item_output, $item, $depth, $args){
if ('menu-1' == $args->theme_location && $item->description)
$item_output = str_replace('', '', $item_output);
return $item_output;
}
add_filter('walker_nav_menu_start_el', 'online_estore_header_menu_desc', 10, 4);
remove_action( 'woocommerce_before_main_content','woocommerce_breadcrumb', 20 );
add_filter( 'woocommerce_show_page_title', '__return_false' );
remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5 );
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
function online_estore_woocommerce_template_loop_product_thumbnail(){ ?>
is_on_sale() == 1 ){
$sale_class = 'new_sale';
}
?>
'.esc_html__('New','online-estore').'';
}
if ( $product->is_on_sale() ) :
echo apply_filters( 'woocommerce_sale_flash', '' . esc_html__( 'Sale!', 'online-estore' ) . '', $post, $product );
endif;
?>
get_date_created() );
if ( ( time() - ( 60 * 60 * 24 * $newness_days ) ) > $created ) {
echo '' . esc_html__( 'New!', 'online-estore' ) . '';
}
if ( $product->is_on_sale() ) :
echo apply_filters( 'woocommerce_sale_flash', '' . esc_html__( 'Sale!', 'online-estore' ) . '', $post, $product );
endif;
?>
get_rating_count();
$average = $product->get_average_rating();
if ( $rating_count > 0 ) : ?>
' . esc_html( $average ) . '',
'5'
); ?>
' . esc_html( $rating_count ) . ''
); ?>
is_on_sale() ) {
if ( ! $product->is_type( 'variable' ) and $product->get_regular_price() and $product->get_sale_price() ) {
$max_percentage = ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100;
} else {
$max_percentage = 0;
foreach ( $product->get_children() as $child_id ) {
$variation = wc_get_product( $child_id );
$price = $variation->get_regular_price();
$sale = $variation->get_sale_price();
$percentage = '';
if ( $price != 0 && ! empty( $sale ) ) $percentage = ( $price - $sale ) / $price * 100;
if ( $percentage > $max_percentage ) {
$max_percentage = $percentage;
}
}
}
echo "" . esc_html( round( - $max_percentage ) ) . esc_html__("%", 'online-estore')."";
}
}
}
if( defined( 'YITH_WCQV' ) ) :
/**
* Online eStore Add the Link to Quick View Function
*
* @return array();
*/
function online_estore_quickview(){
global $product;
$quick_view = YITH_WCQV_Frontend();
remove_action( 'woocommerce_after_shop_loop_item', array( $quick_view, 'yith_add_quick_view_button' ), 15 );
$label = esc_html( get_option( 'yith-wcqv-button-label' ) ); ?>
get_id();
$product_id = intval(isset( $productid ) ? $productid : 0 );
}
$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', 'online-estore' ) );
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 );
}
printf('%s', '#', 'compare link-compare', intval( $product_id ), ''.esc_html( $button_text ).'' );
}
remove_action( 'woocommerce_after_shop_loop_item', array( 'YITH_Woocompare_Frontend', 'add_compare_link' ), 20 );
endif;
if (defined('YITH_WCWL')) {
if ( ! function_exists( 'online_estore_products_wishlist' ) ) {
/**
* Wishlist Header Count Ajax Function
*
* @since 1.0.0
*/
function online_estore_products_wishlist() {
if ( function_exists( 'YITH_WCWL' ) ) {
$wishlist_url = YITH_WCWL()->get_wishlist_url(); ?>
'.$var.'';
};
add_filter( 'yith-wcwl-browse-wishlist-label', 'online_estore_filter_yith_wcwl_browse_wishlist_label', 10, 1 );
}
if( !function_exists( 'online_estore_products_categories_lists' ) ) :
/**
* Product Category list
*
* @return array();
*/
function online_estore_products_categories_lists() {
$args = array(
'taxonomy' => 'product_cat',
'orderby' => 'name',
'show_count' => 0,
'pad_counts' => 0,
'hierarchical' => 1,
'title_li' => '',
'hide_empty' => 0
);
$online_estore_products_categories = get_categories( $args );
$online_estore_products_categories_lists = array();
foreach( $online_estore_products_categories as $category ) {
$online_estore_products_categories_lists[$category->term_id] = $category->name;
}
return $online_estore_products_categories_lists;
}
endif;
if( !function_exists( 'online_estore_products_categories_dropdown' ) ) :
/**
* Widget Single Products Category dropdown
*
* @return array();
*/
function online_estore_products_categories_dropdown() {
$args = array(
'taxonomy' => 'product_cat',
'orderby' => 'name',
'show_count' => 0,
'pad_counts' => 0,
'hierarchical' => 1,
'title_li' => '',
'hide_empty' => 0
);
$online_estore_categories = get_categories( $args );
$online_estore_categories_dropdown = array();
$online_estore_categories_dropdown['0'] = esc_html__( 'Select Block Single Category ', 'online-estore' );
foreach( $online_estore_categories as $category ) {
$online_estore_categories_dropdown[esc_attr( $category->term_id )] = esc_html( $category->name );
}
return $online_estore_categories_dropdown;
}
endif;
if ( !function_exists('online_estore_tabs_ajax_action') ) :
/**
* Online eStore Category Products Ajax Function for Tabs
*
* @return array();
*/
function online_estore_tabs_ajax_action() {
if ( isset( $_POST['category_slug'] ) ) {
$cat_slug = sanitize_text_field( wp_unslash( $_POST['category_slug'] ) );
}
if ( isset( $_POST['product_num'] ) ) {
$product_number = sanitize_text_field( wp_unslash( $_POST['product_num'] ) );
}
if ( isset( $_POST['block_layout'] ) ) {
$block_layout = sanitize_text_field( wp_unslash( $_POST['block_layout'] ) );
}
ob_start(); ?>
'product',
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => $cat_slug
)),
'posts_per_page' => $product_number
);
$query = new WP_Query($product_args);
if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post();
wc_get_template_part('content', 'product');
}
}
wp_reset_postdata();
?>
'product',
'posts_per_page' => $product_number
);
}
elseif($product_type == 'up_products'){
$product_args = array(
'post_type' => 'product',
'meta_key' => 'total_sales',
'orderby' => 'meta_value_num',
'posts_per_page' => $product_number
);
}
elseif($product_type == 'feature_products'){
$product_args = array(
'post_type' => 'product',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'product_visibility',
'field' => 'name',
'terms' => 'featured',
'operator' => 'IN'
)
),
'posts_per_page' => $product_number
);
}
elseif($product_type == 'on_products'){
$product_args = array(
'post_type' => 'product',
'posts_per_page' => $product_number,
'meta_query' => array(
'relation' => 'OR',
array( // Simple products type
'key' => '_sale_price',
'value' => 0,
'compare' => '>',
'type' => 'numeric'
),
array( // Variable products type
'key' => '_min_variation_sale_price',
'value' => 0,
'compare' => '>',
'type' => 'numeric'
)
));
}
$query = new WP_Query($product_args);
if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post();
wc_get_template_part('content', 'product');
}
}
wp_reset_postdata();
?>