Support » Plugin: Product Subtitle For WooCommerce » add_filter(‘wc_product_subtitle_class_checkout_page’…) not working

  • Resolved gutding

    (@gutding)


    Hi there,
    I would like to use WC Product Subtitle in conjunction with Popup Maker. I would like to show a popup if one clicks on a subtitle in a certain product category.
    So I created a small function that alters the regular CSS class name if a product was a member of that category.

    // Eigene Klassen für Kühlware im Plugin WC Product Subtitle
    add_filter('wc_product_subtitle_class_single_product','register_custom_subtitle_class');
    add_filter('wc_product_subtitle_class_shop_page','register_custom_subtitle_class');
    add_filter('wc_product_subtitle_class_checkout_page','register_custom_subtitle_class');
    add_filter('wc_product_subtitle_class_cart_page','register_custom_subtitle_class');
    
    function register_custom_subtitle_class($default_class = null, $display_id = null, $pid = null){
    	$class = $default_class;
    	if ( has_term( 'kuehlware', 'product_cat', $pid ) )
    		{
    			$class = 'product-subtitle-kuehl subtitle-'.$pid;
    		}
    	return $class;
    }

    It works well for the single product and the shop page. But on my cart_page and checkout_page I still have the default <product-subtitle> class instead of the <product-subtitle-kuehl> class, so the popup is not working there…
    Any ideas anybody?
    Thanks for your support and the great product.

    Best regards, Rado

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Ok, this plugin is great but not very well maintained. So I took the liberty to change the source code directl to make it work.
    I did change the original

    public function get_element_defaults($post_id){
    		$default_class = 'product-subtitle subtitle-'.$post_id;
    		$default_id = 'product-subtitle-'.$post_id;
    		$class = apply_filters('wc_product_subtitle_class_'.$this->display_id,$default_class,$this->display_id,$post_id);
    		$id = apply_filters('wc_product_subtitle_id_'.$this->display_id,$default_id,$this->display_id,$post_id);
    		return array('elemid' =>  $id, 'elemclass' => $class);
    	}

    to

    public function get_element_defaults($post_id){
    		$class = 'product-subtitle subtitle-'.$post_id;
    		$id = 'product-subtitle-'.$post_id;
    		if ( has_term( 'kuehlware', 'product_cat', $post_id ) ) {
    			$class = 'product-subtitle-kuehl subtitle-'.$post_id;
    		}
    		return array('elemid' =>  $id, 'elemclass' => $class);
    	}

    in the plugin file wc-product-subtitle/includes/class-tag-handler.php.
    Now it does what it should.

Viewing 1 replies (of 1 total)
  • The topic ‘add_filter(‘wc_product_subtitle_class_checkout_page’…) not working’ is closed to new replies.