0 ) {
return $per_page;
}
return $product_number;
}
}
if ( ! function_exists( 'themeoo_wc_hide_page_title' ) ) {
/**
* Show Title
*
* @return bool
*/
function themeoo_wc_hide_page_title() {
return themeoo_get_mod( 'woocommerce_shop_archive_title' ) == 1;
}
}
if ( ! function_exists( 'themeoo_remove_wc_breadcrumbs' ) ) {
/**
* Remove Shop Page Breadcrumbs as we have default
*
* @return void
*/
function themeoo_remove_wc_breadcrumbs() {
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
}
}
if ( ! function_exists( 'themeoo_wc_remove_result_count' ) ) {
/**
* Remove Shop Filter
*
* @return void
*/
function themeoo_wc_remove_result_count() {
if ( themeoo_get_mod( 'woocommerce_shop_archive_result_count' ) == 0 ) {
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
} else {
add_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
}
}
}
if ( ! function_exists( 'themeoo_wc_remove_archive_short' ) ) {
/**
* Remove Shop Page Filter
*
* @return void
*/
function themeoo_wc_remove_archive_short() {
if ( themeoo_get_mod( 'woocommerce_shop_archive_sort' ) == 0 ) {
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
} else {
add_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
}
}
}
/**
----------------------------------------------------------------------
* Function Hook For Mini Cart
* ----------------------------------------------------------------------*/
if ( ! function_exists( 'themeoo_mini_cart' ) ) :
/**
* If theme option have enable search it will show search after menu item.
*
* @param string $items The HTML list content for the menu items.
* @param stdClass $args An object containing wp_nav_menu() arguments.
*
* @return string
*/
function themeoo_mini_cart( $items, $args ) {
if ( themeoo_get_mod( 'layout_header_show_mini_cart' ) && 'primary' === $args->theme_location ) {
$items .= '';
}
return $items;
}
endif;
if ( ! function_exists( 'themeoo_iconic_cart_count_fragments' ) ) {
/**
* Add item count to cart freagments.
*
* @param array $fragments
*
* @return array
*/
function themeoo_iconic_cart_count_fragments( $fragments ) {
$fragments['li.header-cart-count'] = '';
return $fragments;
}
}
/**
----------------------------------------------------------------------
* Upselss Hook
* ----------------------------------------------------------------------*/
if ( ! function_exists( 'themeoo_wc_change_number_related_products' ) ) {
/**
* WC UpSell display args.
*
* @param array $args Args.
*
* @return array
*/
function themeoo_wc_upsell_display_args( $args ) {
if ( is_product() ) {
$args['posts_per_page'] = themeoo_get_mod( 'woocommerce_single_upsells_count' );
} elseif ( is_cart() ) {
$args['posts_per_page'] = themeoo_get_mod( 'woocommerce_cart_upsells_count' );
} else {
$args['posts_per_page'] = 2;
}
return $args;
}
}
/**
----------------------------------------------------------------------
* Related product
* ----------------------------------------------------------------------*/
if ( ! function_exists( 'themeoo_wc_related_products_limit' ) ) {
/**
* Related product limit.
*
* @return array
*/
function themeoo_wc_related_products_limit() {
if ( is_product() ) {
$args['posts_per_page'] = themeoo_get_mod( 'woocommerce_single_related_item_count' );
} else {
$args['posts_per_page'] = 4;
}
return $args;
}
}
if ( ! function_exists( 'themeoo_cart_cross_sell_total' ) ) {
/**
* Cross Sell Count
*
* @return int
*/
function themeoo_cart_cross_sell_total() {
return absint( themeoo_get_mod( 'woocommerce_cart_cross_sell_count' ) );
}
}
/**
----------------------------------------------------------------------
* WooCommerce Template Override functions
* ----------------------------------------------------------------------*/
/**
----------------------------------------------------------------------
* STOCK
* ----------------------------------------------------------------------*/
if ( ! function_exists( 'themeoo_stock_catalog' ) ) {
/**
* Show product is in stock or out of stock.
*
* @return void
*/
function themeoo_stock_catalog() {
global $product;
if ( $product->is_in_stock() ) {
/* translators: %s: Stock Quantity */
echo ' ' . sprintf( esc_html__( '%s in stock', 'ayyash' ), esc_html( $product->get_stock_quantity() ) ) . '';
} else {
/* translators: %s: Stock Quantity */
echo ' ' . esc_html__( 'out of stock', 'ayyash' ) . '';
}
}
}
/**
----------------------------------------------------------------------
* New Product badge
* ----------------------------------------------------------------------*/
if ( ! function_exists( 'themeoo_woocommerce_new_badge' ) ) {
/**
* Show badge new if product is new.
*
* @return void
*/
function themeoo_woocommerce_new_badge() {
global $product;
$postdate = get_the_time( 'Y-m-d', $product->get_id() ); // Post date.
if ( $postdate ) {
// @phpstan-ignore-next-line
$postdate = strtotime( $postdate ); // Timestamped post date.
$newness = 10; // Newness in days as defined by option.
if ( ( time() - ( 60 * 60 * 24 * $newness ) ) < $postdate ) { // If the product was published within the newness time frame display the new badge.
echo '' . esc_html__( 'New', 'ayyash' ) . '
';
}
}
}
}
if ( ! function_exists( 'themeoo_sale_countdown_timer' ) ) {
/**
* Sale Countdown timer
*
* @return void
*/
function themeoo_sale_countdown_timer() {
global $product;
$sale_date = $product->get_date_on_sale_to();
if ( ! $sale_date ) {
return;
}
echo '';
}
}
if ( ! function_exists( 'themeoo_display_sold_out_loop_woocommerce' ) ) {
/**
* Sold_out hook added
*
* @return void
*/
function themeoo_display_sold_out_loop_woocommerce() {
global $product;
if ( ! $product->is_in_stock() ) {
echo '' . esc_html__( 'Out Of Stock', 'ayyash' ) . '';
}
}
}
if ( ! function_exists( 'themeoo_filter_product_rating_html' ) ) {
/**
* Filter Product rating
*
* @param string $rating_html rating html.
*
* @return string
*/
function themeoo_filter_product_rating_html( $rating_html ) {
global $themeoo_products;
if ( ! $themeoo_products ) {
return $rating_html;
}
if ( isset( $themeoo_products['display_rating'] ) && 'yes' == $themeoo_products['display_rating'] ) {
return $rating_html;
}
return '';
}
}
if ( ! function_exists( 'themeoo_change_number_related_products' ) ) {
/**
* Related Product Column Limit
*
* @param array $args
*
* @return array
*/
function themeoo_change_number_related_products( $args ) {
$args['columns'] = absint( themeoo_get_mod( 'woocommerce_single_related_product_column' ) ); // # of columns per row
return $args;
}
}
if ( ! function_exists( 'themeoo_wc_gallery_thumb_size' ) ) {
/**
* Product Gallery Thumb Image Size Resizing.
*
* @return array
*/
function themeoo_wc_gallery_thumb_size() {
return array(
'width' => 300,
'height' => 300,
'crop' => 0,
);
}
}