• Resolved maven1129

    (@maven1129)


    First question –
    I’d like to know how to apply a custom tab to a categorical level, so that with new product imports assigned to that category, the tabsl woudl automtically apply and the data on import (using your all import add on) would be populated. How do I accomplish that?

    Second question –
    Can we make it to where if the tabs are applied across a category instad of product by product, and that data for that tab on import was blank for a certian product, that tab would just not show until data was populated?

Viewing 1 replies (of 1 total)
  • Hey @maven1129,

    Applying tabs on a category level is something our pro plugin does automatically. I don’t recommend trying to import tabs because they’re saved as post meta. Long story short its just a lot of work and outside the scope of support here. You can import and export your products with their tabs, but there are no means at this time to dynamically import tabs. At that rate you’re so far outside the scope of this plugin you would probably be better off just looking at the WooCommerce docs and coding your own tabs plugin.

    Plenty of examples how to further customize this here:
    https://docs.woocommerce.com/document/editing-product-data-tabs/

    Tabs are just data objects, the “design” part is handled by your theme so you can filter WooCommerce and add more data, which is exactly what this plugin does.

    
    add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
        /**
         * Custom Import Tabs
         *
         * @param array $tabs This is a collection of all your tabs. You can just replace this with a new collection if you want.
         */
        function woo_reorder_tabs( $tabs ) {
    
            // Here you could do conditional checks to see if you're in a category or not.
            // that could be used to trigger a switch statement that filles this $imported_tabs array below.
    
            // Reset tabs to a custom array with our default tabs.
            $imported_tabs = [
                'description'            => $tabs['description'],
                'reviews'                => $tabs['reviews'],
                'additional_information' => $tabs['additional_information'],
                // Import your tabs like this shape with callbacks for the content.
                'product_size'           => [
                    'title'    => __( 'Product Size Chart' ),
                    'callback' => 'yikes_woo_product_size_callback', // see below for callback function.
                    'priority' => 10 // @see WooCommerce Docs these are all shown with examples.
                ]
            ];
    
            return $imported_tabs;
        }
    
        /**
         * Custom Callback
         */
        function yikes_woo_product_size_callback() {
            echo '<h2>Custom Description</h2>';
            echo '<p>Here\'s a custom description</p>';
        }
    

    Cheers,
    Freddie

    • This reply was modified 4 years, 5 months ago by Freddie.
Viewing 1 replies (of 1 total)
  • The topic ‘Apply to categorical or tag level’ is closed to new replies.