'; echo '' . esc_html( '+' ) . ''; echo '' . esc_html( '-' ) . ''; echo ''; } } if ( ! function_exists( 'beetan_product_sale_percentage' ) ) { /** * Product discount percentage */ function beetan_product_sale_percentage() { global $product; $percentages = array(); $product_type = $product->get_type(); $is_on_sale = $product->is_on_sale(); if ( ! $is_on_sale ) { return false; } if ( 'variable' == $product_type ) { $prices = $product->get_variation_prices(); foreach ( $prices['price'] as $key => $price ) { // Only on sale variations if ( $prices['regular_price'][ $key ] !== $price ) { $percentages[] = round( 100 - ( floatval( $prices['sale_price'][ $key ] ) / floatval( $prices['regular_price'][ $key ] ) * 100 ) ); } } // Keep the highest value $percentage = max( $percentages ) . '%'; } elseif ( 'grouped' == $product_type ) { $children_ids = $product->get_children(); foreach ( $children_ids as $child_id ) { $child_product = wc_get_product( $child_id ); $regular_price = (float) $child_product->get_regular_price(); $sale_price = (float) $child_product->get_sale_price(); if ( $sale_price != 0 || ! empty( $sale_price ) ) { $percentages[] = round( 100 - ( $sale_price / $regular_price * 100 ) ); } } // Keep the highest value $percentage = max( $percentages ) . '%'; } else { $regular_price = (float) $product->get_regular_price(); $sale_price = (float) $product->get_sale_price(); if ( $sale_price != 0 || ! empty( $sale_price ) ) { $percentage = round( 100 - ( $sale_price / $regular_price * 100 ) ) . '%'; } else { return false; } } return printf( '%s%s', absint( $percentage ), esc_html__( '% OFF', 'beetan' ) ); } } if ( ! function_exists( 'beetan_product_brand' ) ) { function beetan_product_brand() { $brand_obj = wp_get_object_terms( get_the_ID(), 'product_brand' ); if ( is_wp_error( $brand_obj ) ) { return; } if ( ! empty( $brand_obj ) ) { $brand_array = wp_list_pluck( $brand_obj, 'name' ); $brand_name = implode( ',', $brand_array ); echo '' . esc_html( $brand_name ) . ''; } } } if ( class_exists( 'Woo_Variation_Gallery' ) ) { /** * Additional Variation Image Gallery plugin compatible */ add_filter( 'woo_variation_gallery_default_width', function ( $width ) { $width = 48; return $width; } ); } if ( ! function_exists( 'beetan_shop_product_title' ) ) { /** * Shop product title */ function beetan_shop_product_title() { echo ''; woocommerce_template_loop_product_title(); echo ''; } } if ( ! function_exists( 'beetan_shop_product_img_overlay' ) ) { /** * Shop thumbnail overlay */ function beetan_shop_product_img_overlay() { echo '
'; do_action( 'beetan_shop_thumbnail_overlay_content', get_the_ID() ); echo '
'; } } if ( ! function_exists( 'beetan_shop_item_view_details_button' ) ) { /** * Shop view details button */ function beetan_shop_item_view_details_button() { printf( '%s', esc_url( get_the_permalink() ), esc_html__( 'View Details', 'beetan' ) ); } } if ( ! function_exists( 'beetan_change_shop_pagination_arrow' ) ) { /** * Change shop page pagination arrow * * @param $args * * @return mixed */ function beetan_change_shop_pagination_arrow( $args ) { $args['prev_text'] = 'navigate_before'; $args['next_text'] = 'navigate_next'; return $args; } } if ( ! function_exists( 'beetan_button_proceed_to_checkout' ) ) { /** * Change cart page `Proceed to Checkout` button text */ function beetan_button_proceed_to_checkout() { $button_text = get_theme_mod( 'proceed_to_checkout_button_text' ); if ( ! empty( $button_text ) ) { printf( '%s', esc_url( wc_get_checkout_url() ), esc_html( $button_text ) ); } } } if ( ! function_exists( 'beetan_order_review_wrap_before' ) ) { /** * Checkout wrapper */ function beetan_order_review_wrap_before() { echo '
'; } } add_action( 'woocommerce_checkout_before_order_review_heading', 'beetan_order_review_wrap_before', 5 ); if ( ! function_exists( 'beetan_order_review_wrap_after' ) ) { /** * Checkout wrapper end */ function beetan_order_review_wrap_after() { echo '
'; } } add_action( 'woocommerce_checkout_after_order_review', 'beetan_order_review_wrap_after', 15 ); if ( ! function_exists( 'beetan_is_multistep_checkout' ) ) { /** * Detect multistep checkout page */ function beetan_is_multistep_checkout() { if ( ! beetan_is_woocommerce_active() ) { return false; } return ( is_checkout() && ! is_wc_endpoint_url( 'order-pay' ) && ! is_wc_endpoint_url( 'order-received' ) && ( 'layout-3' === get_theme_mod( 'shop_checkout_layout' ) ) ); } } if ( ! function_exists( 'beetan_multistep_checkout_header' ) ) { /** * Multistep checkout header markup */ function beetan_multistep_checkout_header() { $disable_multistep = apply_filters( 'beetan_disable_multistep_checkout', false ); if ( $disable_multistep || ! beetan_is_multistep_checkout() ) { return; } ?>
'; } } if ( ! function_exists( 'beetan_multistep_checkout_wrap_end' ) ) { /** * Multistep checkout wrap end */ function beetan_multistep_checkout_wrap_end() { echo ''; } } if ( ! function_exists( 'beetan_multistep_checkout_first_step_wrap_start' ) ) { /** * Multistep checkout first step start */ function beetan_multistep_checkout_first_step_wrap_start() { echo '
'; do_action( 'beetan_multistep_checkout_first_step' ); } } if ( ! function_exists( 'beetan_multistep_checkout_first_step_wrap_end' ) ) { /** * Multistep checkout first step end */ function beetan_multistep_checkout_first_step_wrap_end() { ?>
west east
'; } } if ( ! function_exists( 'beetan_multistep_checkout_second_step_wrap' ) ) { /** * Multistep checkout second step start */ function beetan_multistep_checkout_second_step_wrap() { echo '
'; do_action( 'beetan_multistep_checkout_second_step' ); ?> '; } } if ( ! function_exists( 'beetan_multistep_checkout_third_step_wrap' ) ) { /** * Multistep checkout second step start */ function beetan_multistep_checkout_third_step_wrap() { echo '
'; do_action( 'beetan_multistep_checkout_third_step' ); ?> '; } } if ( ! function_exists( 'beetan_button_place_order' ) ) { /** * Change checkout page `Place Order` button */ function beetan_button_place_order( $button_text ) { if ( get_theme_mod( 'change_place_order_button_text', false ) ) { $button_text = get_theme_mod( 'place_order_button_text' ); } $show_price = get_theme_mod( 'enable_price_on_place_order_button', false ); $total_price = ''; if ( $show_price ) { global $woocommerce; if ( isset( $woocommerce->cart->total ) ) { $cart_total = $woocommerce->cart->total; $total_price = ' ' . get_woocommerce_currency_symbol() . $cart_total; } } if ( ! empty( $button_text ) && ! $show_price ) { $button_text = esc_html( $button_text ); } $button_text = $button_text . $total_price; return $button_text; } } add_filter( 'woocommerce_order_button_text', 'beetan_button_place_order' ); if ( ! function_exists( 'beetan_sticky_add_to_cart' ) ) { /** * Single product sticky Add to Cart markup */ function beetan_sticky_add_to_cart() { if ( is_product() ) { global $post; $product = wc_get_product( $post->ID ); if ( ( $product->is_purchasable() && ( $product->is_in_stock() || $product->backorders_allowed() ) ) || $product->is_type( 'external' ) ) { $class = 'beetan-sticky-add-to-cart'; $class .= ' position-' . get_theme_mod( 'sticky_add_to_cart_position', 'bottom' ); $class .= ' visibility-' . get_theme_mod( 'sticky_add_to_cart_visibility', 'desktop-only' ); ?>
', '' ); ?>
is_type( 'simple' ) || $product->is_type( 'external' ) || $product->is_type( 'subscription' ) ) { echo '' . wp_kses_post( $product->get_price_html() ) . ''; woocommerce_template_single_add_to_cart(); } else { echo '' . wp_kses_post( $product->get_price_html() ) . ''; echo '' . esc_html( $product->add_to_cart_text() ) . ''; } ?>