skip to Main Content

WordPress Code Snippets


Set Tax Class for Specific Products in WooCommerce

This snippet allows you to automatically assign a tax class to certain products based on their category or attributes.

add_filter('woocommerce_product_get_tax_class', 'set_tax_class_for_specific_products', 10, 2);
function set_tax_class_for_specific_products($tax_class, $product) {
    if (has_term('your-category', 'product_cat', $product->get_id())) {
        return 'Reduced Rate'; // Change to your desired tax class
    }
    re

I’m a WordPress developer with 10+ years of experience in WooCommerce and custom plugins. I combine technical expertise with design flair to help you create standout, user-friendly websites. Let’s transform your digital presence!

Best WordPress Hosting
Back To Top
Search