• Skip to main content
  • Skip to primary sidebar

WordPress, Genesis Framework and Storefront customization tutorials

  • Archive
    • Free
    • Premium
  • Blog
  • About
  • Contact
  • Newsletter
  • Login
Home » Free » Page 18

Free

Remove product main content editor


//REMOVE PRODUCT MAIN EDITOR - CONTENT EDITOR
function remove_product_editor() {
remove_post_type_support( 'product', 'editor' );
}
add_action( 'init', 'remove_product_editor' );

Filed Under: Free Tagged With: WooCommerce

Change number of products displayed per page


add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );

function new_loop_shop_per_page( $cols ) {
// $cols contains the current number of products per page based on the value stored on Options -> Reading
// Return the number of products you wanna show per page.
$cols = 60;
return $cols;
}

Filed Under: Free Tagged With: WooCommerce

WooCommerce add text to the thank you page order number

//WooCommerce add text to the thank you page order number - rendelésszám

add_action( 'woocommerce_thankyou_order_received_text', 'weitzterez_add_content_thankyou' );

function weitzterez_add_content_thankyou() {
echo '<h2 class="h2thanks">Banki átutalásnál a <strong>rendelés számot</strong> kérlek, írd bele a megjegyzés rovatba!</h2><p class="pthanks"></p>';
}

Filed Under: Free Tagged With: WooCommerce

Add support to zoom gallery


add_action( 'after_setup_theme', 'yourtheme_setup' );
 
function yourtheme_setup() {
 add_theme_support( 'wc-product-gallery-zoom' );
 add_theme_support( 'wc-product-gallery-lightbox' );
 add_theme_support( 'wc-product-gallery-slider' );
}

Filed Under: Free Tagged With: WooCommerce

Remove Zoom, Gallery on Single Product Page


add_action( 'after_setup_theme', 'bbloomer_remove_zoom_lightbox_theme_support', 99 );

function bbloomer_remove_zoom_lightbox_theme_support() {
remove_theme_support( 'wc-product-gallery-zoom' );
remove_theme_support( 'wc-product-gallery-lightbox' );
remove_theme_support( 'wc-product-gallery-slider' );
}

Filed Under: Free Tagged With: WooCommerce

Change add to cart button to view product


/*STEP 1 - REMOVE ADD TO CART BUTTON ON PRODUCT ARCHIVE (SHOP) */

function remove_loop_button(){
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
}
add_action('init','remove_loop_button');

/*STEP 2 -ADD NEW BUTTON THAT LINKS TO PRODUCT PAGE FOR EACH PRODUCT */

add_action('woocommerce_after_shop_loop_item','replace_add_to_cart');
function replace_add_to_cart() {
global $product;
$link = $product->get_permalink();
echo do_shortcode('<a href="'.$link.'" class="button addtocartbutton">Megtekintés</a>');
}

Filed Under: Free Tagged With: WooCommerce

Add Tabs after Add to cart button


//Add Tabs after Add to cart button
add_action( 'woocommerce_single_product_summary', 'wc_custom_show_attributes_outside_tabs', 35 );
function wc_custom_show_attributes_outside_tabs() {
global $product;
$product->list_attributes();
}

Filed Under: Free Tagged With: WooCommerce

Remove Additional informations


//Remove Additional informations
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );

function woo_remove_product_tabs( $tabs ) {
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
}

Filed Under: Free Tagged With: tab, WooCommerce

Send customer directly to the checkout


//send customer directly to the checkout
add_filter('add_to_cart_redirect', 'theme_prefix_add_to_cart_redirect');
function theme_prefix_add_to_cart_redirect() {
global $woocommerce;
$checkout_url = $woocommerce->cart->get_checkout_url();
return $checkout_url;
}

Filed Under: Free Tagged With: WooCommerce

Remove quantity field


//REMOVE QUANTITY FIELD
add_filter( 'woocommerce_is_sold_individually', 'wc_remove_all_quantity_fields', 10, 2 );
function wc_remove_all_quantity_fields( $return, $product ) {
return( true );
}

Filed Under: Free Tagged With: WooCommerce

Change add to cart button text


//CHANGE ADD TO CART BUTTON TEXT
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_single_add_to_cart_text' ); // 2.1 +

function woo_custom_single_add_to_cart_text() {

return __( 'Kosárba teszem', 'woocommerce' );

}

Filed Under: Free Tagged With: WooCommerce

Add post category to body class


// =========================================================================
// ADD POST CATEGORY TO BODY CLASS
// =========================================================================
function add_category_to_body_class( $classes ) {
	if ( !is_single() )
	return $classes;
	$post_categories = get_the_category();
		foreach( $post_categories as $current_category ) {
			$classes[] = 'category-' . $current_category->slug;
		}
	return $classes;
	}
add_filter( 'body_class', 'add_category_to_body_class' );

Filed Under: Free Tagged With: PHP

Add product category to body class


//ADD PRODUCT CATEGORY TO BODY CLASS

add_filter( 'body_class', 'bbloomer_wc_product_cats_css_body_class' );

function bbloomer_wc_product_cats_css_body_class( $classes ){
if( is_singular( 'product' ) )
{
$custom_terms = get_the_terms(0, 'product_cat');
if ($custom_terms) {
foreach ($custom_terms as $custom_term) {
$classes[] = 'product_cat_' . $custom_term->slug;
}
}
}
return $classes;
}

Filed Under: Free Tagged With: category, WooCommerce

Add text to specific product category

Version 1

// =========================================================================
// ADD TEXT TO SPECIFIC PRODUCT CATEGORY
// =========================================================================
function function_name( $attr ) {
    global $product;
    if ( has_term( 'category_name', 'product_cat', $product->get_id() ) ) {
        echo 'TESZT';
    }
    return $attr;
}
add_filter( 'woocommerce_share', 'function_name' );

Version 2


// =========================================================================
// ADD TEXT TO SPECIFIC PRODUCT CATEGORY
// =========================================================================
function add_text_to_spec_cat() {
    global $post;
    $terms = wp_get_post_terms( $post->ID, 'product_cat' );
    foreach ( $terms as $term ) $categories[] = $term->slug;
    if ( in_array( 'szivar', $categories ) ) {
        echo 'TESZT';
    }
}
add_filter( 'woocommerce_after_single_product', 'add_text_to_spec_cat' );

Filed Under: Free Tagged With: WooCommerce

Change position of add-to-cart on single product


remove_action( 'woocommerce_single_product_summary',
'woocommerce_template_single_price', 10 );
add_action( 'woocommerce_single_product_summary',
'woocommerce_template_single_price', 30 );

Filed Under: Free Tagged With: WooCommerce

Hook revslider in Storefront


//HOOK REVSLIDER
add_filter( 'storefront_before_content', 'add_revslider' );

function add_revslider( $rev_slider ) {
    if ( is_front_page() ) {
        echo do_shortcode('[rev_slider alias="revslider"]');
    }
return $rev_slider;
}

Filed Under: Free Tagged With: Storefront

Fix collapsed related products


//FIX COLLAPSED RELATED PRODUCTS
add_filter( 'woocommerce_after_single_product_summary', 'add_clear_both' );
function add_clear_both( $clear_both ) {
echo '<div class="clear"></div>';
return $clear_both;
}

Filed Under: Free Tagged With: WooCommerce

Add text with function


//ADD TEXT VIA FUNCTION
add_filter( 'ultimatum_print_footer', 'add_barion_banner' );
function add_barion_banner( $barion_banner ) {
echo 'TESZT';
return $barion_banner;
}

Filed Under: Free Tagged With: PHP

Product category shortcode

[product_category category=”” per_page=”40″ columns=”3″ orderby=”rand”]

Filed Under: Free Tagged With: WooCommerce

New order e-mail custom text if coupon is used

// New order e-mail custom text if coupon is used
add_filter( 'woocommerce_email_after_order_table', 'add_custom_email_text' );

function add_custom_email_text($order) {
if ($order->get_used_coupons()){
echo '';
}
else{
echo '';
}
}

Filed Under: Free Tagged With: WooCommerce

  • « Go to Previous Page
  • Page 1
  • Interim pages omitted …
  • Page 16
  • Page 17
  • Page 18
  • Page 19
  • Go to Next Page »

Primary Sidebar

Gabor Flamich

Hi! I'm Gabor.
I write tutorials on WordPress and WooCommerce.

MacBook

12 Essential Snippets for Genesis Developers

Subscribe to my Newsletter to view my basic collection of Genesis snippets that I use for my projects!

Sign Up for Free
  • Facebook
  • GitHub
  • Instagram
  • LinkedIn
  • Twitter
  • YouTube
UpdraftPlus Premium

Tags

ACF Ajax Analytics API Bootstrap Breadcrumb category CPT CSS fetch FSE Genesis Google Maps Gutenberg HTML Isotope JavaScript jQuery loop Map Menu Parallax PHP Rest API SASS SEO SQL Storefront SVG tab tag manager tags Taxonomy Tool upsell Webpack Wholesale WooCommerce WordPress WPML

Disclosure: Some of the links in this site are affiliate links. I will be paid a commission if you use this link to make a purchase.

  • Privacy Policy / Terms of Service
© 2025 WP Flames - All Right Reserved