Support » Plugin: KIA Subtitle » Problems with plugin and woocommerce 3.0

  • Resolved daanvdu

    (@daanvdu)


    Hello,

    First of all, thank you for your plugin. I use it for a long time and it works very well.
    After the update of woocommerce 3.0 I got some trouble with the plugin.
    I used the following code to get the subtitle below the product title and also in my cart and on the checkout page after the product title.

    function kia_add_subtitle_to_woocommerce(){
    if( function_exists( ‘the_subtitle’ ) ) the_subtitle( ‘<h6 class=”subtitle”>’, ‘</h6>’ );
    }
    add_action( ‘woocommerce_single_product_summary’, ‘kia_add_subtitle_to_woocommerce’, 7 );

    function kia_subtitle_for_woocommerce_products( $title, $product ){

    if( function_exists( ‘get_the_subtitle’ ) && $subtitle = get_the_subtitle( $product->id ) ){
    $title .= ‘ | ‘ . $subtitle;
    }
    return $title;
    }
    add_filter( ‘woocommerce_product_title’, ‘kia_subtitle_for_woocommerce_products’, 10, 2 );

    After the update of woocommerce the subtitle isn’t shown at the cart and checkout page.
    Are there more people with this problem?

    I think the ‘woocommerce_product_title’ doens’t exists anymore….

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author helgatheviking

    (@helgatheviking)

    Looks like there are two factors that need updating in my compatibility code. 1. the cart doesn’t run the title through the woocommerce_product_title filter, it calls $product->get_name() which is run through the woocommerce_product_get_name filter instead. And 2. $product->id needs to be updated to $product->get_id():

    function kia_add_subtitle_to_woocommerce(){
    	if( function_exists( 'the_subtitle' ) ) the_subtitle( '<h6 class=”subtitle”>', '</h6>' );
    }
    add_action( 'woocommerce_single_product_summary', 'kia_add_subtitle_to_woocommerce', 7 );
    
    function kia_subtitle_for_woocommerce_products( $title, $product ){
    
    	if( function_exists( 'get_the_subtitle' ) && $subtitle = get_the_subtitle( $product->get_id() ) ){
    		$title .= ' | ' . $subtitle;
    	}
    	return $title;
    }
    add_filter( 'woocommerce_product_get_name', 'kia_subtitle_for_woocommerce_products', 10, 2 );

    This was were I was looking for!

    Thank you so much for your quick response.

    Hi,
    is it possible to show the subtitle in the product category page?

    thanks a lot for helping

    Hello,
    Thanks for the updated PHP. It seems that it works for simple products but not for Variable product variations in the cart/checkout. Is there another filter that must be applied?

    Thanks!
    W

    Plugin Author helgatheviking

    (@helgatheviking)

    Presumably that’s because the subtitle is saved as meta against the parent product. So when getting the name of the variation, no subtitle meta exists.

    I don’t have time to test it, but perhaps something like this will work:

    
    function kia_subtitle_for_woocommerce_products( $title, $product ) {
    
    	if( function_exists( 'get_the_subtitle' ) ) {
    		$subtitle = $product->is_type( 'variation' ) ? get_the_subtitle( $product->get_id() ) : get_the_subtitle( $product->get_parent_id() );
    		$title .= ' | ' . $subtitle;
    	}
    	return $title;
    }
    add_filter( 'woocommerce_product_get_name', 'kia_subtitle_for_woocommerce_products', 10, 2 );
    
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Problems with plugin and woocommerce 3.0’ is closed to new replies.