cart->get_cart_contents_count(); ?>
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( 'upstudy-woocommerce-style', $inline_font );
}
/** ===== Add woocommerce woocommerce-active class on body === */
add_filter( 'body_class', 'upstudy_woocommerce_body_class' );
function upstudy_woocommerce_body_class( $classes ) {
$classes[] = 'woocommerce woocommerce-active';
return $classes;
}
/** ===== Shop page product per page === */
add_filter( 'loop_shop_per_page', 'upstudy_woocommerce_shop_products' );
function upstudy_woocommerce_shop_products() {
$cols = Upstudy::setting( 'woo_shop_per_page' );
return $cols;
}
/** ===== Add markup before main content === */
add_action( 'woocommerce_before_main_content', 'upstudy_woocommerce_markup_before' );
if ( ! function_exists( 'upstudy_woocommerce_markup_before' ) ) :
function upstudy_woocommerce_markup_before() {
echo '';
echo '';
}
endif;
/** ===== Add markup after main content === */
add_action( 'woocommerce_after_main_content', 'upstudy_woocommerce_markup_after' );
if ( ! function_exists( 'upstudy_woocommerce_markup_after' ) ) :
function upstudy_woocommerce_markup_after() {
echo '';
echo '
';
}
endif;
/** ===== Add single product page class === */
add_filter( 'upstudy_woo_content_area_class', 'upstudy_woo_single_content_class' );
if ( ! function_exists( 'upstudy_woo_single_content_class' ) ) :
function upstudy_woo_single_content_class( $args ) {
if ( is_singular( 'product' ) ) :
return 'content-area upstudy-main-content-inner upstudy-container';
else :
return $args;
endif;
}
endif;
/** ===== Shop page header top are === */
add_action( 'woocommerce_before_shop_loop', 'woocommerce_before_shop_loop_top_area', 20 );
if ( ! function_exists( 'woocommerce_before_shop_loop_top_area' ) ) :
function woocommerce_before_shop_loop_top_area() {
wc_get_template( 'tpl-part/loop-top-area.php' );
}
endif;
/** ===== Related products === */
if ( ! function_exists( 'upstudy_woocommerce_output_related_products' ) ) :
function upstudy_woocommerce_output_related_products() {
$show = Upstudy::setting( 'shop_related_show' );
if ( $show ) :
echo '';
wc_get_template( 'tpl-part/related-products.php' );
echo '
';
endif;
}
endif;
/** ===== WooCommerce cart link fragment === */
add_filter( 'woocommerce_add_to_cart_fragments', 'upstudy_woocommerce_add_to_cart_fragments' );
if ( ! function_exists( 'upstudy_woocommerce_add_to_cart_fragments' ) ) :
function upstudy_woocommerce_add_to_cart_fragments( $fragments ) {
ob_start();
upstudy_woocommerce_cart_link();
$fragments['a.cart-contents'] = ob_get_clean();
return $fragments;
}
endif;
/** ===== WooCommerce mini cart fragments === */
add_filter( 'woocommerce_add_to_cart_fragments', 'upstudy_woocommerce_add_to_cart_fragments' );
if ( ! function_exists( 'upstudy_woocommerce_add_to_cart_fragments' ) ) :
function upstudy_woocommerce_add_to_cart_fragments( $fragments ) {
$fragments['span.upstudy-woo-mini-cart-total-item'] = '' . WC()->cart->get_cart_contents_count() . '';
$fragments['span.upstudy-woo-mini-cart-total-price'] = '' . WC()->cart->get_cart_subtotal() . '';
return $fragments;
}
endif;
/** ===== WooCommerce cart link === */
if ( ! function_exists( 'upstudy_woocommerce_cart_link' ) ) :
function upstudy_woocommerce_cart_link() {
?>
cart->get_cart_contents_count(), 'upstudy' ),
WC()->cart->get_cart_contents_count()
);
?>
cart->get_cart_subtotal() ); ?>
0 && ! empty( $decimal_separator ) ) :
$origin_price = str_replace( $decimal_separator, '' . $decimal_separator, $formatted_price );
$origin_price .= '';
return $origin_price;
endif;
return $formatted_price;
}
endif;
/** ===== Price separator === */
if ( ! function_exists( 'upstudy_woocommerce_product_price_offer' ) ) :
function upstudy_woocommerce_product_price_offer() {
global $product;
if( $product->is_on_sale() && $product->is_in_stock() && ! $product->is_type( 'variable' ) ) :
$regular_price = $product->get_regular_price();
$sale_price = $product->get_price();
$percentage = round( 100 - ( $sale_price / $regular_price * 100 ) ) . '%';
$percentage = apply_filters( 'upstudy_woo_product_price_percent', $percentage );
$prefix = apply_filters( 'upstudy_woo_product_percent_prefix', '-' );
return '' . esc_html( $prefix ) . esc_html( $percentage ) . '';
endif;
return;
}
endif;
/** ===== Price separator === */
if ( ! function_exists( 'upstudy_woocommerce_featured_product_tag' ) ) :
function upstudy_woocommerce_featured_product_tag() {
global $product;
if ( $product->is_featured() && $product->is_in_stock() ) :
$tag = apply_filters( 'upstudy_featured_product_tag_text', __( 'Hot', 'upstudy' ) );
return '' . esc_html( $tag ) . '';
endif;
return;
}
endif;
/** ===== Price separator === */
if ( ! function_exists( 'upstudy_woo_single_product_top_content' ) ) :
function upstudy_woo_single_product_top_content() {
if ( upstudy_woocommerce_featured_product_tag() || upstudy_woocommerce_product_price_offer() ) :
echo '';
echo upstudy_woocommerce_featured_product_tag();
echo upstudy_woocommerce_product_price_offer();
echo '
';
endif;
}
endif;
/** ===== Price separator === */
if ( ! function_exists( 'upstudy_woo_single_product_rating' ) ) :
function upstudy_woo_single_product_rating( $rating_only = false ) {
global $product;
$rating_count = $product->get_rating_count();
$count_total_rating = $product->get_review_count();
$average = $product->get_average_rating();
if ( $count_total_rating && wc_review_ratings_enabled() ) :
echo '';
echo wc_get_rating_html( $average, $rating_count );;
if ( $rating_only ) :
echo '
';
$reviews_title = sprintf( esc_html( _n( '(%1$s Review)', '(%1$s Reviews)', $count_total_rating, 'upstudy' ) ), esc_html( $count_total_rating ) );
echo wp_kses_post( $reviews_title );
echo '
';
else :
echo '(' . esc_html($average ) . ')';
endif;
echo '
';
endif;
}
endif;
/** ===== WooCommerce Dynamic Sidebar === */
add_action( 'woocommerce_before_main_content', 'upstudy_woocommerce_dynamic_sidebar');
if ( ! function_exists( 'upstudy_woocommerce_dynamic_sidebar' ) ) :
function upstudy_woocommerce_dynamic_sidebar() {
$sidebar_layout = 'sidebar_upstudy_sidebar_name';
echo dynamic_sidebar( $sidebar_layout );
}
endif;
/** ===== Shop Page Top Sidebar */
add_action( 'woocommerce_before_shop_loop', 'upstudy_wc_sidebar_shop_top_area');
if ( ! function_exists( 'upstudy_wc_sidebar_shop_top_area' ) ) :
function upstudy_wc_sidebar_shop_top_area() {
if (is_active_sidebar('woocommerce_shop_page_top_sidebar')) {
dynamic_sidebar('woocommerce_shop_page_top_sidebar');
}
}
endif;
/** ===== Shop Single Page Top Sidebar */
add_action( 'woocommerce_before_single_product', 'upstudy_wc_sidebar_product_single_top');
if ( ! function_exists( 'upstudy_wc_sidebar_product_single_top' ) ) :
function upstudy_wc_sidebar_product_single_top() {
if (is_active_sidebar('woocommerce_product_page_top_sidebar')) {
dynamic_sidebar('woocommerce_product_page_top_sidebar');
}
}
endif;
/** ===== Add/Removed Actions === */
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
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 );
add_filter( 'woocommerce_product_description_heading', '__return_null' );
add_filter( 'woocommerce_product_additional_information_heading', '__return_null' );
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 5 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
add_action( 'woocommerce_after_single_product_summary', 'upstudy_woocommerce_output_related_products', 20 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 6 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 35 );
// Remove default WooCommerce product title
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
// Add custom product title with dynamic tag
add_action( 'woocommerce_single_product_summary', 'upstudy_custom_product_title', 5 );
function upstudy_custom_product_title() {
// Get the tag from customizer
$tag = get_theme_mod( 'single_product_title_tag', 'h2' );
// Print the product title with chosen tag
the_title( '<' . esc_attr( $tag ) . ' class="product_title entry-title">', '' . esc_attr( $tag ) . '>' );
}
/**
* Single product wrapper start
*
* @since 1.0.0
*/
if ( ! function_exists( 'upstudy_woocommerce_single_product_summary_start' ) ) :
function upstudy_woocommerce_single_product_summary_start() {
echo '';
}
endif;
/**
* Single product wrapper end
*
* @since 1.0.0
*/
if ( ! function_exists( 'upstudy_woocommerce_single_product_summary_end' ) ) :
function upstudy_woocommerce_single_product_summary_end() {
echo '
';
}
endif;
/**
* product review submit button content change
*
* @since 1.0.0
*/
if ( ! function_exists( 'upstudy_woocommerce_product_review_submit_button' ) ) :
function upstudy_woocommerce_product_review_submit_button( $comment_form ){
$comment_form['submit_button'] = '';
return $comment_form;
}
endif;
add_filter( 'woocommerce_product_review_comment_form_args', 'upstudy_woocommerce_product_review_submit_button' );
/**
* product review user thumb size
*
* @since 1.0.0
*/
if ( ! function_exists( 'upstudy_woocommerce_review_list_avatar_size' ) ) :
function upstudy_woocommerce_review_list_avatar_size(){
return 80;
}
endif;
/**
* remove zoom hover effect on WooCommerce Product Details Page
*
* @since 1.0.0
*/
if ( ! function_exists( 'upstudy_remove_image_zoom_support' ) ) :
function upstudy_remove_image_zoom_support() {
remove_theme_support( 'wc-product-gallery-zoom' );
remove_theme_support( 'wc-product-gallery-lightbox' );
}
endif;
/**
* Desible WooCommerce setup wizard
*/
add_filter( 'woocommerce_enable_setup_wizard', 'upstudy_disable_wizard' );
function upstudy_disable_wizard(){
return false;
}