theme_location === 'primary') {
$items .= '';
}
return $items;
}
endif;
function rox_iconic_cart_count_fragments($fragments)
{
$fragments['li.header-cart-count'] = '';
return $fragments;
}
add_filter('wp_nav_menu_items', 'rox_mini_cart', 10, 2);
add_filter('woocommerce_add_to_cart_fragments', 'rox_iconic_cart_count_fragments', 10, 1);
/*----------------------------------------------------------------------
* Wishlist
*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------
* Upselss Hook
*----------------------------------------------------------------------*/
add_filter('woocommerce_upsell_display_args', 'wc_change_number_related_products');
function wc_change_number_related_products($args)
{
if (is_product()) {
$args['posts_per_page'] = rox_get_mod('woocommerce_single_upsells_count');
} elseif (is_cart()) {
$args['posts_per_page'] = rox_get_mod('woocommerce_cart_upsells_count');
}else{
$args['posts_per_page']=2;
}
return $args;
}
/*----------------------------------------------------------------------
* Related product
*----------------------------------------------------------------------*/
function rox_woo_related_products_limit()
{
global $product;
if (is_product()) {
$args['posts_per_page'] = rox_get_mod('woocommerce_single_related_item_count');
} else {
$args['posts_per_page'] = 4;
}
return $args;
}
add_filter('woocommerce_output_related_products_args', 'rox_woo_related_products_limit');
/*----------------------------------------------------------------------
* Cross Sell Count
*----------------------------------------------------------------------*/
add_filter('woocommerce_cross_sells_total', 'rox_cart_cross_sell_total');
function rox_cart_cross_sell_total($total) {
$total = rox_get_mod('woocommerce_cart_cross_sell_count');
return $total;
}
/*----------------------------------------------------------------------
* Enable Product Zoom
*----------------------------------------------------------------------*/
if(rox_get_mod('woocommerce_general_enable_product_zoom')){
add_theme_support( 'wc-product-gallery-zoom' );
} else {
remove_theme_support( 'wc-product-gallery-zoom' );
}
/*----------------------------------------------------------------------
* Enable Product Lightbox
*----------------------------------------------------------------------*/
if(rox_get_mod('woocommerce_general_enable_product_lightbox')){
add_theme_support( 'wc-product-gallery-lightbox' );
} else {
remove_theme_support( 'wc-product-gallery-lightbox' );
}
/*----------------------------------------------------------------------
* Enable Product Gallery Slider
*----------------------------------------------------------------------*/
if(rox_get_mod('woocommerce_general_enable_product_gallery_slider')){
add_theme_support( 'wc-product-gallery-slider' );
} else {
remove_theme_support( 'wc-product-gallery-slider' );
}
/*----------------------------------------------------------------------
* WooCommerce Template Override functions
*----------------------------------------------------------------------*/
//product-content
if ( !function_exists('')){
function rox_woocommerce_before_shop_loop_item(){
/*
* Function Name : rox_woocommerce_before_shop_loop_item
* Description :
* Function Hooked : woocommerce_before_shop_loop_item
* Function return Type : html
* Function Since : 1.0.0
*/
?>
Its a Test
is_in_stock() ) {
echo ' ' . $product->get_stock_quantity() . __( ' in stock', 'ayyash' ) . '';
} else {
echo ' '. __( 'out of stock', 'ayyash' ) .'';
}
}
/*----------------------------------------------------------------------
* New Product badge
*----------------------------------------------------------------------*/
function rox_woocommerce_new_badge( ) {
/*
* Function Name : rox_woocommerce_new_badge
* Description : show badge new if product is new
* Function Hooked : woocommerce_before_shop_loop_item
* Function return Type : html
* Function Since : 1.0.0
*/
global $product;
$postdate = get_the_time( 'Y-m-d' ,$product->get_id()); // Post date
$postdatestamp = strtotime( $postdate ); // Timestamped post date
$newness = 10; // Newness in days as defined by option
if ( ( time() - ( 60 * 60 * 24 * $newness ) ) < $postdatestamp ) { // If the product was published within the newness time frame display the new badge
echo '' . esc_html__('New', 'ayyash') . '
';
}
}
/*----------------------------------------------------------------------
*
*----------------------------------------------------------------------*/
function rox_sale_countdown_timer( ) {
global $product;
$sale_date = $product->get_date_on_sale_to();
if( ! $sale_date ) return;
echo '';
}
/**
* Override theme default specification for product # per row
*/
function loop_columns() {
$loop_columns = rox_get_mod('woocommerce_shop_archive_column');
return $loop_columns;
}
add_filter('loop_shop_columns', 'loop_columns', 999);
//Override the_excerpt
function tn_custom_excerpt_length( $length ) {
$excerpt_length = rox_get_mod('layout_blog_excerpt_length');
return $excerpt_length;
}
add_filter( 'excerpt_length', 'tn_custom_excerpt_length', 999 );
//sold_out hook added
function rox_display_sold_out_loop_woocommerce() {
global $product;
if ( !$product->is_in_stock() ) {
echo '' . __( 'Out Of Stock', 'ayyash' ) . '';
}
}
add_action( 'woocommerce_before_shop_loop_item_title', 'rox_display_sold_out_loop_woocommerce' );
function rox_filter_product_rating_html( $rating_html ){
global $rox_products;
if( ! $rox_products ) return $rating_html;
if( isset( $rox_products['display_rating'] ) && $rox_products['display_rating'] == 'yes' ) return $rating_html;
return "";
}
/*----------------------------------------------------------------------
* Related Product Column Limit
*----------------------------------------------------------------------*/
add_filter( 'woocommerce_output_related_products_args', 'rox_change_number_related_products', 9999 );
function rox_change_number_related_products( $args ) {
$args['columns'] = rox_get_mod('woocommerce_single_related_product_column'); // # of columns per row
return $args;
}
/*----------------------------------------------------------------------
* Product Gallery Thumb Image Size Resizing
*----------------------------------------------------------------------*/
add_filter( 'woocommerce_get_image_size_gallery_thumbnail', function( $size ) {
return array(
'width' => 300,
'height' => 300,
'crop' => 0,
);
} );