暫無描述

cross-sells.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Cross-sells
  4. *
  5. * This template can be overridden by copying it to yourtheme/woocommerce/cart/cross-sells.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 4.4.0
  16. */
  17. defined( 'ABSPATH' ) || exit;
  18. if ( $cross_sells ) : ?>
  19. <div class="cross-sells">
  20. <?php
  21. $heading = apply_filters( 'woocommerce_product_cross_sells_products_heading', __( 'You may be interested in&hellip;', 'woocommerce' ) );
  22. if ( $heading ) :
  23. ?>
  24. <h2><?php echo esc_html( $heading ); ?></h2>
  25. <?php endif; ?>
  26. <?php woocommerce_product_loop_start(); ?>
  27. <?php foreach ( $cross_sells as $cross_sell ) : ?>
  28. <?php
  29. $post_object = get_post( $cross_sell->get_id() );
  30. setup_postdata( $GLOBALS['post'] =& $post_object ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited, Squiz.PHP.DisallowMultipleAssignments.Found
  31. wc_get_template_part( 'content', 'product' );
  32. ?>
  33. <?php endforeach; ?>
  34. <?php woocommerce_product_loop_end(); ?>
  35. </div>
  36. <?php
  37. endif;
  38. wp_reset_postdata();