Modyfikacje woocommerce

Zmiany i modyfikacje w obrębie breadcrumbs:

/**
 * Rename "home" in breadcrumb
 */
add_filter( 'woocommerce_breadcrumb_defaults', 'nws_change_breadcrumb_home_text' );
function nws_change_breadcrumb_home_text( $defaults ) {
    // Change the breadcrumb home text from 'Home'
	$defaults['home'] = 'All products';
	return $defaults;
}


/**
 * Change the breadcrumb separator
 */
add_filter( 'woocommerce_breadcrumb_defaults', 'nws_change_breadcrumb_delimiter' );
function nws_change_breadcrumb_delimiter( $defaults ) {
	// Change the breadcrumb delimeter from '/'
	$defaults['delimiter'] = ' | ';
	return $defaults;
}


/**
 * Replace the home link URL
 */
add_filter( 'woocommerce_breadcrumb_home_url', 'nws_custom_breadrumb_home_url' );
function nws_custom_breadrumb_home_url() {
    return '/shop/';
}


/**
 * Change number or products per row to 3
 */
add_filter('loop_shop_columns', 'loop_columns', 999);
if (!function_exists('loop_columns')) {
	function loop_columns() {
    if( is_product_category() ) {
  		return 3; // 3 products per row
    } else {
      return 4;
    }
	}
}


/**
 * Remove breadcrumbs on specific pages
 */
add_action('template_redirect', 'remove_shop_breadcrumbs' );
function remove_shop_breadcrumbs(){

    if (is_product_category())
        remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0);

}


Modyfikacja strony koszyka/Cart

/**
 * Add text before cart form
 */
add_action('woocommerce_after_cart', 'nws_add_after_cart', 1);
function nws_add_after_cart() {
    echo '<h1>hello</h1>';
}

/**
 * Add text after open div.cart_totals 
 */
add_action( 'woocommerce_before_cart_totals', 'custom_before_cart_totals' );
function custom_before_cart_totals() {
        echo '<p>new important info</p>';                                                
}

—-

#woocommerce

Agnieszka Trefler

Agnieszka Trefler (Ruda) - freelancer, web developer, specjalistka od WordPressa z Wrocławia. Z pasją budowania stron, blogowania i fotografowania. Twórca Inspiracji fotograficznych.