Change ‘landingpage’ in My Account

13. August 2020

**
 * Change landingpage on My account page
 */
function twstudio_subscriptions_as_myaccount_home(){
	if ( is_account_page() && empty( WC()->query->get_current_endpoint() ) ){
		wp_safe_redirect( wc_get_account_endpoint_url( 'subscriptions' ) );
		exit;
	}
}
add_action( 'template_redirect', 'twstudio_subscriptions_as_myaccount_home' );

Goes into functions.php. Change ‘subscriptions’ to your endpoint of choise.

Replace ‘Dismiss’ with an X in Woo store notice

2. April 2020

function twstudio_demo_store_filter($text) {

	$text = str_replace(array('<p class="woocommerce-store-notice demo_store">', '</p>', 'Dismiss'), array('<div class="woo-notice-container"><p class="woocommerce-store-notice demo_store">', '</p></div>', 'X'), $text);
	return $text;
}
add_filter('woocommerce_demo_store', 'twstudio_demo_store_filter', 10, 1);
Remove Uncategorized from widget

20. March 2020

function remove_uncategorized_category( $terms, $taxonomy, $query_vars, $term_query ) {
if ( is_admin() )
return $terms; if ( $taxonomy[0] == 'product_cat' ) {
foreach ( $terms as $k => $term ) {
if ( $term->term_id == get_option( 'default_product_cat' ) ) {
unset( $terms[$k] );
}
}
} return $terms;
}
add_filter( 'get_terms', 'remove_uncategorized_category', 10, 4 );
Add a empty cart button to cart page

6. February 2020

// Adds a EMPTY CART button to cart
add_action( 'init', 'woocommerce_clear_cart_url' );
function woocommerce_clear_cart_url() {
	global $woocommerce;

	if ( isset( $_GET['empty-cart'] ) ) {
		$woocommerce->cart->empty_cart();
	}
}

add_action( 'woocommerce_cart_actions', 'tws_add_clear_cart_button', 20 );
function tws_add_clear_cart_button() {
	echo "<a class='button empty-button' href='?empty-cart=true'>" . __( 'Tøm handlekurv', 'woocommerce' ) . "</a>";
}
Remove surname from comments

2. December 2019

Change of this field: .woocommerce-review__author

/**
 * Change the comment name to show only Firstname.
 */
function twstudio_my_comment_author( $author = '' ) {

	$comment = get_comment( $comment_ID );
	if ( ! empty( $comment->comment_author ) ) {
		if ( $comment->user_id > 0 ) {
			$user   = get_userdata( $comment->user_id );
			$author = $user->first_name . ' ' . substr( $user->last_name, 0, 0 ) . '';
		} else {
			$author = __( 'No name' );
		}
	}

	return $author;
}

add_filter( 'get_comment_author', 'twstudio_my_comment_author', 10, 1 );
Add custom field to the ‘My Account’

13. March 2019

Remember to create a new ACF field and set the Location to ‘User Form is equal to Add /edit’ (‘Brukerskjema er lik Legg til / Rediger’)

Hide the product’s weight and dimensions

7. January 2019

Enable/Disable the ‘Ship to a different address?’ checkbox

10. December 2018

To Enable:

To Disable:

Change WooCommerce Email style

22. August 2018

 

Remove the redundant words from WooCommerce Tabs

31. July 2018

Goes into woocommerce.php

Update cart without the update button in cart.php

31. July 2018

Goes into woocommerce.php or functions.php

 

Add TILBEHØR (accessories) to WC Tab on single product page

30. July 2018

Add extra space to the breadcrumbs

30. July 2018

Goes into woocommerce.php (or functions.php, but you should have a woocommerce.php if you have woocommerce running on your site)

 

Check if a product is in stock

27. July 2018

 

Change the default ‘Sale’ text to custom

24. July 2018

Goes into functions.php:

 

Change sorting

2. July 2018

Change sorting on products that are ‘connected’ to a product

Goes into the functions.php

Change the orderby and order, to change order.

If you just going to change Standart sorting on all Products. Go to: WooCommerce -> Settings -> Products -> Display -> Default Product Sorting

Add Length, Height and Width to Single-product

16. May 2018

Goes into functions.php

Edit text in WooCommerce Message Error

20. April 2018

Search fix. Hide hidden products when searching.

20. April 2018