add-to-cart
3 years ago
tabs
5 years ago
meta.php
5 years ago
photoswipe.php
5 years ago
price.php
5 years ago
product-attributes.php
5 years ago
product-image.php
5 years ago
product-thumbnails.php
5 years ago
rating.php
5 years ago
related.php
5 years ago
review-meta.php
5 years ago
review-rating.php
5 years ago
review.php
5 years ago
sale-flash.php
5 years ago
share.php
5 years ago
short-description.php
5 years ago
stock.php
5 years ago
title.php
5 years ago
up-sells.php
5 years ago
related.php
55 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Related Products |
| 4 | * |
| 5 | * This template can be overridden by copying it to yourtheme/woocommerce/single-product/related.php. |
| 6 | * |
| 7 | * HOWEVER, on occasion WooCommerce will need to update template files and you |
| 8 | * (the theme developer) will need to copy the new files to your theme to |
| 9 | * maintain compatibility. We try to do this as little as possible, but it does |
| 10 | * happen. When this occurs the version of the template file will be bumped and |
| 11 | * the readme will list any important changes. |
| 12 | * |
| 13 | * @see https://docs.woocommerce.com/document/template-structure/ |
| 14 | * @package WooCommerce\Templates |
| 15 | * @version 3.9.0 |
| 16 | */ |
| 17 | |
| 18 | if ( ! defined( 'ABSPATH' ) ) { |
| 19 | exit; |
| 20 | } |
| 21 | |
| 22 | if ( $related_products ) : ?> |
| 23 | |
| 24 | <section class="related products"> |
| 25 | |
| 26 | <?php |
| 27 | $heading = apply_filters( 'woocommerce_product_related_products_heading', __( 'Related products', 'woocommerce' ) ); |
| 28 | |
| 29 | if ( $heading ) : |
| 30 | ?> |
| 31 | <h2><?php echo esc_html( $heading ); ?></h2> |
| 32 | <?php endif; ?> |
| 33 | |
| 34 | <?php woocommerce_product_loop_start(); ?> |
| 35 | |
| 36 | <?php foreach ( $related_products as $related_product ) : ?> |
| 37 | |
| 38 | <?php |
| 39 | $post_object = get_post( $related_product->get_id() ); |
| 40 | |
| 41 | setup_postdata( $GLOBALS['post'] =& $post_object ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited, Squiz.PHP.DisallowMultipleAssignments.Found |
| 42 | |
| 43 | wc_get_template_part( 'content', 'product' ); |
| 44 | ?> |
| 45 | |
| 46 | <?php endforeach; ?> |
| 47 | |
| 48 | <?php woocommerce_product_loop_end(); ?> |
| 49 | |
| 50 | </section> |
| 51 | <?php |
| 52 | endif; |
| 53 | |
| 54 | wp_reset_postdata(); |
| 55 |