>
>
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 .= '
  • ' . WC()->cart->get_cart_contents_count() . '
  • '; } 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'] = '
  • ' . WC()->cart->get_cart_contents_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, ); } } /** * Product Attribute Radio buttons * * @param string $html Data. * @param array $args Arguments. * * @return string */ function themeoo_variation_radio_buttons( $html, $args ) { $args = wp_parse_args( $args, [ 'options' => false, 'attribute' => false, 'product' => false, 'selected' => false, 'name' => '', 'id' => '', 'class' => '', 'show_option_none' => __( 'Choose an option', 'ayyash' ), ] ); /** * @var WC_Product_Variable $product */ $product = $args['product']; $options = $args['options']; $attribute = $args['attribute']; $name = ! $args['name'] ? 'attribute_' . sanitize_title( $attribute ) : $args['name']; if ( false === $args['selected'] && $args['attribute'] && $args['product'] instanceof WC_Product ) { $selected_key = 'attribute_' . sanitize_title( $args['attribute'] ); $selected = isset( $_REQUEST[ $selected_key ] ) ? wc_clean( wp_unslash( $_REQUEST[ $selected_key ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $args['selected'] = ! $selected ? $product->get_variation_default_attribute( $args['attribute'] ) : $selected; } if ( empty( $options ) && ! empty( $product ) && ! empty( $attribute ) ) { //@phpstan-ignore-line $attributes = $product->get_variation_attributes(); $options = $attributes[ $attribute ]; } $radios = '
    '; // Attribute label. $attrib_name = wc_attribute_label( $attribute, $product ); if ( ! empty( $options ) ) { if ( $product && taxonomy_exists( $attribute ) ) { //@phpstan-ignore-line $terms = wc_get_product_terms( $product->get_id(), $attribute, [ 'fields' => 'all' ] ); foreach ( $terms as $term ) { if ( in_array( $term->slug, $options, true ) ) { $id = $name . '-' . $term->slug; $opt_name = apply_filters( 'woocommerce_variation_option_name', $term->name ); $title = sprintf( /* translators: 1. attribute label, 2. attribute value. */ _x( '%1$s: %2$s', 'Product attribute option tooltip.', 'ayyash' ), $attrib_name, $opt_name ); $output = 'term_id, 'color', true ); $color = ! $color ? strtolower( $term->name ) : $color; $output .= 'style="background-color: ' . esc_attr( $color ) . '">'; $output .= 'swatch'; } else { $output .= '>' . esc_html( $term->name ); } $output .= ''; $radios .= 'slug, false ) . '>'; } } } else { foreach ( $options as $option ) { $id = $name . '-' . $option; $output = apply_filters( 'woocommerce_variation_option_name', $option ); $title = sprintf( /* translators: 1. attribute label, 2. attribute value. */ _x( '%1$s: %2$s', 'Product attribute option tooltip.', 'ayyash' ), $attrib_name, $output ); $output = '' . esc_html( $output ) . ''; $checked = sanitize_title( $args['selected'] ) === $args['selected'] ? checked( $args['selected'], sanitize_title( $option ), false ) : checked( $args['selected'], $option, false ); $radios .= ''; } } } $radios .= '
    '; return $html . $radios; } /** * Check Product Variation. * * @param bool $active Activate. * @param WC_Product_Variation $variation Variation. * * @return bool */ function themeoo_variation_check( $active, $variation ) { if ( ! $variation->is_in_stock() && ! $variation->backorders_allowed() ) { return false; } return $active; } // End of file themeoo-woocommerce-hook-helper.php