bmex63

WooCommerce Up-Sells Tab

May 10th, 2013
496
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15);
  2. add_filter( 'woocommerce_product_tabs', 'accessories_tab');
  3. function accessories_tab_content() {
  4.  
  5. global $product, $woocommerce, $woocommerce_loop;
  6.  
  7. $upsells = $product->get_upsells();
  8.  
  9. if ( sizeof( $upsells ) == 0 ) return;
  10.  
  11. $args = array(
  12.     'post_type'           => 'product',
  13.     'ignore_sticky_posts' => 1,
  14.     'no_found_rows'       => 1,
  15.     'posts_per_page'      => $posts_per_page,
  16.     'orderby'             => $orderby,
  17.     'post__in'            => $upsells,
  18.     'post__not_in'        => array( $product->id ),
  19. );
  20.  
  21. $products = new WP_Query( $args );
  22.  
  23. $woocommerce_loop['columns']    = $columns;
  24.  
  25. if ( $products->have_posts() ) : ?>
  26.  
  27.     <div class="upsells products">
  28.  
  29.         <h2><?php _e( 'You may also like&hellip;', 'woocommerce' ) ?></h2>
  30.  
  31.         <?php woocommerce_product_loop_start(); ?>
  32.  
  33.             <?php while ( $products->have_posts() ) : $products->the_post(); ?>
  34.  
  35.                 <?php woocommerce_get_template_part( 'content', 'product' ); ?>
  36.  
  37.             <?php endwhile; // end of the loop. ?>
  38.  
  39.         <?php woocommerce_product_loop_end(); ?>
  40.  
  41.     </div>
  42.  
  43. <?php endif;
  44.  
  45. wp_reset_postdata();
  46.  
  47. }
  48.  
  49. function accessories_tab($tabs) {
  50.  $tabs['test_tab'] = array(
  51.  'title' => __( 'Accessories', 'woocommerce' ),
  52.  'priority' => 50,
  53.  'callback' => 'accessories_tab_content'
  54.  );
  55.  
  56.  return $tabs;
  57. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×