• Skip to main content
  • Skip to primary sidebar

WordPress, Genesis Framework and Storefront customization tutorials

  • Archive
    • Free
    • Premium
  • Blog
  • About
  • Contact
  • Newsletter
  • Membership
  • Login
Home » WooCommerce » Page 5

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

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

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

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/');
*/

Filed Under: Free Tagged With: WooCommerce

  • « Go to Previous Page
  • Go to page 1
  • Interim pages omitted …
  • Go to page 3
  • Go to page 4
  • Go to page 5

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 Genesis Google Maps Gutenberg HTML Isotope JavaScript jQuery loop Map Menu Parallax PHP 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
© 2023 WP Flames - All Right Reserved