//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(); }
Free
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; }
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; }
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 ); }
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' ); }
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' );
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; }
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' );
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 );
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; }
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; }
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; }
Product category shortcode
[product_category category=”” per_page=”40″ columns=”3″ orderby=”rand”]
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 ''; } }
Redirect after registration
//Redirect after registration add_filter( 'woocommerce_registration_redirect', 'custom_redirection_after_registration', 10, 1 ); function custom_redirection_after_registration( $redirection_url ){ if ( WC()->cart->get_cart_contents_count() == 0 ) { $redirection_url = get_permalink( wc_get_page_id( 'shop' ) ); }else{ // Change the redirection Url $redirection_url = wc_get_checkout_url(); //Checkout } return $redirection_url; // Always return something } /* "Home" Url: $redirection_url = get_home_url(); "Shop" Url: $redirection_url = get_permalink( wc_get_page_id( 'shop' ) ); "Cart" Url: $redirection_url = wc_get_cart_url(); "Checkout" Url: $redirection_url = wc_get_checkout_url(); "Account" $redirection_url = get_permalink( wc_get_page_id( 'myaccount' ) ); "ID": $redirection_url = get_permalink( $post_id ); (where $post_id is the id of the post or the page) Get post or pages by path (example): $redirection_url = home_url('/product/ninja/'); */