related.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * Related Products
  4. *
  5. * @author WooThemes
  6. * @package WooCommerce/Templates
  7. * @version 3.0.0
  8. */
  9. if ( ! defined( 'ABSPATH' ) ) {
  10. exit; // Exit if accessed directly
  11. }
  12. global $product, $woocommerce_loop;
  13. if ( empty( $product ) || ! $product->exists() ) {
  14. return;
  15. }
  16. $related = wc_get_related_products( get_the_ID(), $posts_per_page );
  17. if ( count( $related ) === 0 ) return;
  18. $args = apply_filters( 'woocommerce_related_products_args', array(
  19. 'post_type' => 'product',
  20. 'ignore_sticky_posts' => 1,
  21. 'no_found_rows' => 1,
  22. 'posts_per_page' => $posts_per_page,
  23. 'orderby' => $orderby,
  24. 'post__in' => $related,
  25. 'post__not_in' => array( $product->get_id() ),
  26. ) );
  27. $products = new WP_Query( $args );
  28. $columns = intval( $columns );
  29. $max_columns = $columns;
  30. if ( 0 === $columns ) {
  31. $columns = 4; // this is used for thumbnails only
  32. }
  33. $woocommerce_loop['columns'] = $columns;
  34. echo '<div class="limit-wrapper vamtam-box-outer-padding">';
  35. echo '<h4 class="vamtam-wc-related-title">' . esc_html__( 'Related Products', 'vamtam-consulting' ) . '</h4>';
  36. echo '</div>';
  37. echo '<div class="vamtam-related-content">';
  38. echo '<div class="limit-wrapper vamtam-box-outer-padding">';
  39. include locate_template( array( 'templates/woocommerce-scrollable/loop.php' ) );
  40. echo '</div>';
  41. echo '</div>';