403Webshell
Server IP : 103.48.194.25  /  Your IP : 216.73.216.74
Web Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.33
System : Linux VMHostDefault 3.10.0-1160.42.2.el7.x86_64 #1 SMP Tue Sep 7 14:49:57 UTC 2021 x86_64
User : sieuthimay ( 1016)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/sieuthimayasia.com/public_html/wp-content/themes/mtw-maycn/inc/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/sieuthimayasia.com/public_html/wp-content/themes/mtw-maycn/inc/woocommerce.php
<?php
/**
 * Woocommerce functions.
 * 
 * @package  MTWTeam
 */
global $post, $product, $woocommerce, $rating_html, $rating;

 /**
 * Filter Woocommerce Sale Flash.
 * 
 * @return string Sale flash.
 */
function mtwfn_sale_flash() {
	global $post, $product;

	if ( $product->is_on_sale() && $product->get_sale_price() ) :

		$regular = $product->get_regular_price();
		$sale = $product->get_sale_price();

		$per = ( $regular - $sale ) / $regular * 100;

		$per = sprintf( '- %s&#37', absint( $per ) );

		return apply_filters( 'mtwfn_sale_flash', '<span class="onsale">' . $per . '</span>', $post, $product );

	endif;
}
add_filter( 'woocommerce_sale_flash', 'mtwfn_sale_flash', $post, $product );

// Action Woocommerce hook.
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
add_action( 'woocommerce_after_single_product_summary', 'mtwfn_under_single_product', 15 );
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
add_action( 'woocommerce_before_shop_loop_item_title', 'mtwfn_template_loop_product_thumbnail', 15 );
remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 );
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 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 25 );
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 );
add_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_sale_flash', 25 );

/**
 * Under single product.
 */
function mtwfn_under_single_product() {
	if ( is_active_sidebar( 'under-single-product' ) ) {
		dynamic_sidebar( 'under-single-product' );
	}
}

/**
 * Remove product description heading.
 * 
 * @return string empty string.
 */
function mtwfn_remove_product_description_heading() {
	return '';
}
add_filter( 'woocommerce_product_description_heading', 'mtwfn_remove_product_description_heading' );

/**
 * Returns the product rating in html format.
 *
 * @param string $rating (default: '')
 *
 * @return string
 */
function mtwfn_get_rating_html( $rating = null ) {
	global $product;

	$rating_html = '';

	if ( ! is_numeric( $rating ) ) {
		$rating = $product->get_average_rating();

		if ( ! $rating ) {
			$rating = 0;
		}
	}

	$rating_html  = '<div class="star-rating" title="' . sprintf( __( 'Rated %s out of 5', 'woocommerce' ), $rating ) . '">';

	$rating_html .= '<span style="width:' . ( ( $rating / 5 ) * 100 ) . '%"><strong class="rating">' . $rating . '</strong> ' . __( 'out of 5', 'woocommerce' ) . '</span>';

	$rating_html .= '</div>';

	return apply_filters( 'mtwfn_product_get_rating_html', $rating_html, $rating );
}
add_filter( 'woocommerce_product_get_rating_html', 'mtwfn_get_rating_html', $rating_html, $rating );

if ( ! function_exists( 'mtwfn_get_product_thumbnail' ) ) {
	/**
	 * Get the product thumbnail, or the placeholder if not set.
	 *
	 * @subpackage	Loop
	 * @param string $size (default: 'shop_catalog')
	 * @param int $deprecated1 Deprecated since WooCommerce 2.0 (default: 0)
	 * @param int $deprecated2 Deprecated since WooCommerce 2.0 (default: 0)
	 * @return string
	 */
	function mtwfn_get_product_thumbnail( $size = 'shop_catalog', $deprecated1 = 0, $deprecated2 = 0 ) {
		global $post;

		$image_size = apply_filters( 'mtwfn_single_product_archive_thumbnail_size', $size );

		if ( has_post_thumbnail() ) {
			$props = wc_get_product_attachment_props( get_post_thumbnail_id(), $post );
			return get_the_post_thumbnail( $post->ID, $image_size, array(
				'alt'    => $props['alt'],
			) );
		} elseif ( wc_placeholder_img_src() ) {
			return wc_placeholder_img( $image_size );
		}
	}
}

if ( ! function_exists( 'mtwfn_template_loop_product_thumbnail' ) ) {

	/**
	 * Get the product thumbnail for the loop.
	 *
	 * @subpackage	Loop
	 */
	function mtwfn_template_loop_product_thumbnail() {
		woocommerce_template_loop_product_link_open();
		echo mtwfn_get_product_thumbnail();
		woocommerce_template_loop_product_link_close();
	}
}

/**
 * Count of Cart.
 * 
 * @return number $count number of product.
 */
function mtwfn_cart_count() {
	if ( function_exists( 'WC' ) ) {
		$count = sprintf ( _n( '%d', '%d', WC()->cart->cart_contents_count ), WC()->cart->cart_contents_count );
	} else {
		$count = '0';
	}

	return $count;
}

/**
* mtwfn_woocommerce_after_shop_loop_item_open
*/
function mtwfn_woocommerce_after_shop_loop_item_open() {
	echo '<div class="ncn_cart_wrap clearfix">';
}
add_action( 'woocommerce_after_shop_loop_item', 'mtwfn_woocommerce_after_shop_loop_item_open', 5 );

/**
* mtwfn_woocommerce_after_shop_loop_item_close
*/
function mtwfn_woocommerce_after_shop_loop_item_close() {
	echo '</div>';
}
add_action( 'woocommerce_after_shop_loop_item', 'mtwfn_woocommerce_after_shop_loop_item_close', 20 );

/**
* mtwfn_woocommerce_template_loop_product_title
*/
function mtwfn_woocommerce_template_loop_product_title() {
	the_title( '<h3 class="ncn_products_title text-center"><a href="' . get_the_permalink() . '">', '</a></h3>' );
}
add_action( 'woocommerce_shop_loop_item_title', 'mtwfn_woocommerce_template_loop_product_title', 10 );

/**
 * mtwfn_woocommerce_product_add_to_cart_text
*/
function mtwfn_woocommerce_product_add_to_cart_text() {
	global $product;

	$product_type = $product->product_type;
	
	switch ( $product_type ) {
		case 'external':
			return __( 'Mua ngay', 'maycn' );
		break;
		case 'grouped':
			return __( 'Xem sản phẩm', 'maycn' );
		break;
		case 'simple':
			return __( 'Mua ngay', 'maycn' );
		break;
		case 'variable':
			return __( 'Lựa chọn', 'maycn' );
		break;
		default:
			return __( 'Đọc thêm', 'maycn' );
	}
	
}
add_filter( 'woocommerce_product_add_to_cart_text' , 'mtwfn_woocommerce_product_add_to_cart_text' );
 
/**
* mtwfn_woocommerce_archive_custom_cart_button_text
*/
function mtwfn_woocommerce_archive_custom_cart_button_text() {
	return __( 'Mua ngay', 'maycn' );
}
add_filter( 'woocommerce_product_add_to_cart_text', 'mtwfn_woocommerce_archive_custom_cart_button_text' );

/**
 * Adds Addthis share button.
 */
function mtwfn_addthis_share() {
	echo '<div class="addthis_inline_share_toolbox mt-10"></div><!-- Go to www.addthis.com/dashboard to customize your tools --> <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5819c2e7c69162fc"></script>';
}
//add_action( 'woocommerce_share', 'mtwfn_addthis_share', 5 );

Youez - 2016 - github.com/yon3zu
LinuXploit