includes(); $this->hooks(); do_action( 'beetan_woocommerce_loaded', $this ); } /** * Includes */ public function includes() { require_once get_template_directory() . '/inc/woocommerce/woocommerce-functions.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound } /** * Hooks */ public function hooks() { add_action( 'after_setup_theme', array( $this, 'setup_theme' ) ); add_filter( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); add_filter( 'body_class', array( $this, 'body_class' ) ); add_action( 'wp', array( $this, 'woocommerce_init' ), 1 ); add_action( 'wp', array( $this, 'product_customize' ), 5 ); add_action( 'widgets_init', array( $this, 'register_widgets' ) ); add_action( 'woocommerce_before_main_content', array( $this, 'woocommerce_wrapper_before' ) ); add_action( 'woocommerce_after_main_content', array( $this, 'woocommerce_wrapper_after' ) ); add_action( 'woocommerce_before_shop_loop', array( $this, 'shop_toolbar_open' ) ); add_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 20 ); add_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 25 ); add_action( 'woocommerce_before_shop_loop', array( $this, 'shop_layout_buttons' ), 30 ); add_action( 'woocommerce_before_shop_loop', array( $this, 'shop_toolbar_close' ), 40 ); add_filter( 'woocommerce_add_to_cart_fragments', array( $this, 'woocommerce_cart_link_fragment' ) ); add_filter( 'woocommerce_output_related_products_args', array( $this, 'related_products_args' ) ); add_filter( 'beetan_get_sidebar', array( $this, 'replace_sidebar' ) ); } public function shop_toolbar_open() { echo '
'; } public function shop_layout_buttons() { if ( ! is_shop() && ! is_product_taxonomy() ) { return; } echo ''; } /** * WooCommerce setup theme */ public function setup_theme() { add_theme_support( 'woocommerce', array( 'thumbnail_image_width' => 150, 'single_image_width' => 300, 'product_grid' => array( 'default_rows' => 3, 'min_rows' => 1, 'default_columns' => 4, 'min_columns' => 1, 'max_columns' => 6, ), ) ); add_theme_support( 'wc-product-gallery-zoom' ); add_theme_support( 'wc-product-gallery-lightbox' ); add_theme_support( 'wc-product-gallery-slider' ); } /** * WooCommerce specific scripts & stylesheets. */ public function enqueue_scripts() { $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_style( 'beetan-woocommerce-style', esc_url( get_theme_file_uri( "/assets/css/woocommerce{$suffix}.css" ) ), array(), beetan_assets_version( "/assets/css/woocommerce{$suffix}.css" ) ); $font_path = WC()->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( 'beetan-woocommerce-style', $inline_font ); wp_enqueue_script( 'beetan-woocommerce-scripts', esc_url( get_theme_file_uri( "/assets/js/woocommerce{$suffix}.js" ) ), array( 'jquery' ), beetan_assets_version( "/assets/js/woocommerce{$suffix}.js" ), true ); } /** * Add 'woocommerce-active' class to the body tag. * * @param $classes * * @return mixed */ public function body_class( $classes ) { $classes[] = 'woocommerce-active'; return $classes; } /** * Remove WooCommerce Default actions */ public function woocommerce_init() { remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 ); remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 ); remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 ); } /** * WooCommerce Default Shop Product Customization */ public function product_customize() { remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5 ); remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 ); add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_link_close', 10 ); add_action( 'woocommerce_shop_loop_item_title', 'beetan_shop_product_title', 10 ); add_action( 'woocommerce_shop_loop_item_title', 'beetan_product_sale_percentage', 8 ); add_action( 'woocommerce_shop_loop_item_title', 'beetan_product_brand', 9 ); add_action( 'woocommerce_before_shop_loop_item_title', 'beetan_shop_product_img_overlay', 20 ); add_action( 'beetan_shop_thumbnail_overlay_content', 'beetan_shop_item_view_details_button', 15 ); add_filter( 'woocommerce_pagination_args', 'beetan_change_shop_pagination_arrow' ); // Enable Quantity +/- button if ( get_theme_mod( 'product_quantity_plus_minus_button', true ) ) { add_action( 'woocommerce_after_quantity_input_field', 'beetan_product_quantity_button' ); } // Hide cart page coupon form if ( is_cart() && get_theme_mod( 'hide_coupon_cart_page', false ) ) { add_filter( 'woocommerce_coupons_enabled', '__return_false' ); } // Change cart page `Proceed to Checkout` button text if ( ! empty( get_theme_mod( 'proceed_to_checkout_button_text' ) ) && get_theme_mod( 'change_proceed_to_checkout_button_text', false ) ) { remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 ); add_action( 'woocommerce_proceed_to_checkout', 'beetan_button_proceed_to_checkout', 20 ); } // Remove cart page cross-sells from default position remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' ); // Cart cross-sell if ( get_theme_mod( 'enable_cart_cross_sells', true ) ) { // Add cart page cross-sells UNDER the cart table if ( 'layout-2' === get_theme_mod( 'shop_cart_layout', 'layout-1' ) && get_theme_mod( 'sticky_cart_totals' ) ) { add_action( 'woocommerce_after_cart_table', 'woocommerce_cross_sell_display' ); } else { add_action( 'woocommerce_after_cart', 'woocommerce_cross_sell_display' ); } // Cross-sells columns add_filter( 'woocommerce_cross_sells_columns', function ( $columns ) { return get_theme_mod( 'cart_cross_sells_columns', 3 ); } ); // Cross-sells products limit add_filter( 'woocommerce_cross_sells_total', function ( $limit ) { return get_theme_mod( 'cart_cross_sells_products_limit', 3 ); } ); } if ( defined( 'YITH_WCQV' ) ) { remove_action( 'woocommerce_after_shop_loop_item', array( YITH_WCQV_Frontend(), 'yith_add_quick_view_button' ), 15 ); add_action( 'beetan_shop_thumbnail_overlay_content', array( YITH_WCQV_Frontend(), 'yith_add_quick_view_button' ), 10 ); } add_filter( 'woocommerce_sale_flash', '__return_false' ); } /** * WooCommerce Before Content Wrapper. * * @return void */ public function woocommerce_wrapper_before() { echo '