403Webshell
Server IP : 104.171.130.249  /  Your IP : 216.73.216.146
Web Server : nginx/1.25.5
System : Linux 0dac65491b7e 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64
User : root ( 0)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/html/wp-content/themes/matreshka/inc/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/wp-content/themes/matreshka/inc/woocommerce-core.php
<?php
/**
 * WooCommerce storefront behavior shared across cart, catalog, and search.
 */

/**
 * Clear cart functionality
 */
function matreshka_clear_cart() {
	if ( isset( $_GET['empty-cart'] ) && 'true' === $_GET['empty-cart'] ) {
		if ( function_exists( 'WC' ) && WC()->cart ) {
			WC()->cart->empty_cart();
			wp_safe_redirect( wc_get_cart_url() );
			exit;
		}
	}
}
add_action( 'init', 'matreshka_clear_cart' );

/**
 * Ensure WooCommerce uses theme templates
 */
function matreshka_woocommerce_template_path() {
	return 'woocommerce/';
}
add_filter( 'woocommerce_template_path', 'matreshka_woocommerce_template_path' );

/**
 * Disable WooCommerce default stylesheets (optional - if you want full control)
 */
// add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );
/**
 * Remove "Cart updated" message on cart page
 */
function matreshka_clear_cart_updated_notices() {
	// Clear notices after cart update
	if ( function_exists( 'is_cart' ) && is_cart() && ! empty( $_POST['update_cart'] ) ) {
		// Add a small delay to let WooCommerce add its message first
		add_action( 'woocommerce_cart_updated', function() {
			wc_clear_notices();
		}, 999 );
	}
}
add_action( 'wp_loaded', 'matreshka_clear_cart_updated_notices', 1 );

/**
 * Remove cart updated message using filter
 */
function matreshka_hide_cart_update_message( $translated_text, $text, $domain ) {
	// Hide "Cart updated" message
	if ( $domain === 'woocommerce' && function_exists( 'is_cart' ) && is_cart() ) {
		if ( strpos( $text, 'Cart updated' ) !== false ||
		     strpos( $text, 'Корзина обновлена' ) !== false ) {
			return '';
		}
	}
	return $translated_text;
}
add_filter( 'gettext', 'matreshka_hide_cart_update_message', 20, 3 );

/**
 * Redirect after cart update to prevent form resubmission dialog
 * Using PRG (Post-Redirect-Get) pattern
 */
function matreshka_redirect_after_cart_update() {
	// Check if cart was just updated
	if ( function_exists( 'is_cart' ) && is_cart() && ! empty( $_POST['update_cart'] ) ) {
		// Get current cart URL
		$cart_url = wc_get_cart_url();

		// Redirect to same page using GET to prevent resubmission
		wp_safe_redirect( $cart_url );
		exit;
	}
}
add_action( 'template_redirect', 'matreshka_redirect_after_cart_update', 1 );

/**
 * Make search work with WooCommerce products
 */
function matreshka_search_products_only( $query ) {
	if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) {
		// Only search in products
		$query->set( 'post_type', 'product' );

		// Log for debugging
		error_log( 'Search query: ' . $query->get( 's' ) );
	}
}
add_action( 'pre_get_posts', 'matreshka_search_products_only' );

Youez - 2016 - github.com/yon3zu
LinuXploit