How to add the function to another plugin?
-
Hi Author,
We need to add the custom tabs to another quick view plugin, I tried to add the functions at xoo-qv-core.php, however, it doesn’t recognize the code.
// Summary
add_action( ‘xoo-qv-summary’, ‘woocommerce_product_description_tab’, 35 );
add_action( ‘xoo-qv-summary’, ‘yikes_woo_filter_all_product_tabs’, 40 );Any suggestions will be a great help, many thanks!
-
Hey @tecxie,
As you can see from the screenshot by using this code I was able to get the tabs into quickview. You’ll also need to use some javascript that I borrowed from WooCommerces Single Product JS. Ideally the JS should be in another file file as well that is enqueued once this code is called but for the sake of time I just included it directly when I was running my test.
add_action( 'xoo-qv-summary', 'yikes_add_tabs_to_quick_view', '100' ); function yikes_add_tabs_to_quick_view() { woocommerce_output_product_data_tabs(); ?> <script> (function( $ ) { $( 'body' ) // Tabs .on( 'init', '.wc-tabs-wrapper, .woocommerce-tabs', function() { $( '.wc-tab, .woocommerce-tabs .panel:not(.panel .panel)' ).hide(); var hash = window.location.hash; var url = window.location.href; var $tabs = $( this ).find( '.wc-tabs, ul.tabs' ).first(); if ( hash.toLowerCase().indexOf( 'comment-' ) >= 0 || hash === '#reviews' || hash === '#tab-reviews' ) { $tabs.find( 'li.reviews_tab a' ).click(); } else if ( url.indexOf( 'comment-page-' ) > 0 || url.indexOf( 'cpage=' ) > 0 ) { $tabs.find( 'li.reviews_tab a' ).click(); } else if ( hash === '#tab-additional_information' ) { $tabs.find( 'li.additional_information_tab a' ).click(); } else { $tabs.find( 'li:first a' ).click(); } } ) .on( 'click', '.wc-tabs li a, ul.tabs li a', function( e ) { e.preventDefault(); var $tab = $( this ); var $tabs_wrapper = $tab.closest( '.wc-tabs-wrapper, .woocommerce-tabs' ); var $tabs = $tabs_wrapper.find( '.wc-tabs, ul.tabs' ); $tabs.find( 'li' ).removeClass( 'active' ); $tabs_wrapper.find( '.wc-tab, .panel:not(.panel .panel)' ).hide(); $tab.closest( 'li' ).addClass( 'active' ); $tabs_wrapper.find( $tab.attr( 'href' ) ).show(); } ) // Review link .on( 'click', 'a.woocommerce-review-link', function() { $( '.reviews_tab a' ).click(); return true; } ) // Star ratings for comments .on( 'init', '#rating', function() { $( '#rating' ) .hide() .before( '<p class="stars">\ <span>\ <a class="star-1" href="#">1</a>\ <a class="star-2" href="#">2</a>\ <a class="star-3" href="#">3</a>\ <a class="star-4" href="#">4</a>\ <a class="star-5" href="#">5</a>\ </span>\ </p>' ); } ) .on( 'click', '#respond p.stars a', function() { var $star = $( this ), $rating = $( this ).closest( '#respond' ).find( '#rating' ), $container = $( this ).closest( '.stars' ); $rating.val( $star.text() ); $star.siblings( 'a' ).removeClass( 'active' ); $star.addClass( 'active' ); $container.addClass( 'selected' ); return false; } ) .on( 'click', '#respond #submit', function() { var $rating = $( this ).closest( '#respond' ).find( '#rating' ), rating = $rating.val(); if ( $rating.length > 0 && ! rating && wc_single_product_params.review_rating_required === 'yes' ) { window.alert( wc_single_product_params.i18n_required_rating_text ); return false; } } ); // Init Tabs and Star Ratings $( '.wc-tabs-wrapper, .woocommerce-tabs, #rating' ).trigger( 'init' ); } )( jQuery ); </script> <?php }Cheers,
FreddieWe haven’t heard back from you in a while, so I’ll mark this thread as resolved now. If you have some more questions, feel free to start a new thread or comment here and I’ll get back to you!
Cheers,
Freddie
The topic ‘How to add the function to another plugin?’ is closed to new replies.