Advertisement
nshelper

Untitled

Jan 12th, 2024
817
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.71 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Cart Page
  4.  *
  5.  * This template can be overridden by copying it to yourtheme/woocommerce/cart/cart.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://woo.com/document/template-structure/
  14.  * @package WooCommerce\Templates
  15.  * @version 7.9.0
  16.  */
  17.  
  18. defined( 'ABSPATH' ) || exit;
  19.  
  20. do_action( 'woocommerce_before_cart' ); ?>
  21.  
  22. <form class="woocommerce-cart-form" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">
  23.     <?php do_action( 'woocommerce_before_cart_table' ); ?>
  24.  
  25.     <table class="shop_table shop_table_responsive cart woocommerce-cart-form__contents" cellspacing="0">
  26.         <thead>
  27.             <tr>
  28.                 <th class="product-remove"><span class="screen-reader-text"><?php esc_html_e( 'Remove item', 'woocommerce' ); ?></span></th>
  29.                 <th class="product-thumbnail"><span class="screen-reader-text"><?php esc_html_e( 'Thumbnail image', 'woocommerce' ); ?></span></th>
  30.                 <th class="product-name"><?php esc_html_e( 'Product', 'woocommerce' ); ?></th>
  31.                 <th class="product-price"><?php esc_html_e( 'Price', 'woocommerce' ); ?></th>
  32.                 <th class="product-quantity"><?php esc_html_e( 'Quantity', 'woocommerce' ); ?></th>
  33.                 <th class="product-subtotal"><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?></th>
  34.             </tr>
  35.         </thead>
  36.         <tbody>
  37.             <?php do_action( 'woocommerce_before_cart_contents' ); ?>
  38.  
  39.             <?php
  40.             foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
  41.                 do_action( 'woocommerce/cart_loop/start', $cart_item );
  42.                 $_product   = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
  43.                 $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
  44.                 /**
  45.                  * Filter the product name.
  46.                  *
  47.                  * @since 2.1.0
  48.                  * @param string $product_name Name of the product in the cart.
  49.                  * @param array $cart_item The product in the cart.
  50.                  * @param string $cart_item_key Key for the product in the cart.
  51.                  */
  52.                 $product_name = apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key );
  53.  
  54.                 if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
  55.                     $product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key );
  56.                     ?>
  57.                     <tr class="woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
  58.  
  59.                         <td class="product-remove">
  60.                             <?php
  61.                                 echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  62.                                     'woocommerce_cart_item_remove_link',
  63.                                     sprintf(
  64.                                         '<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">&times;</a>',
  65.                                         esc_url( wc_get_cart_remove_url( $cart_item_key ) ),
  66.                                         /* translators: %s is the product name */
  67.                                         esc_attr( sprintf( __( 'Remove %s from cart', 'woocommerce' ), wp_strip_all_tags( $product_name ) ) ),
  68.                                         esc_attr( $product_id ),
  69.                                         esc_attr( $_product->get_sku() )
  70.                                     ),
  71.                                     $cart_item_key
  72.                                 );
  73.                             ?>
  74.                         </td>
  75.  
  76.                         <td class="product-thumbnail">
  77.                         <?php
  78.                         $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
  79.  
  80.                         if ( ! $product_permalink ) {
  81.                             echo $thumbnail; // PHPCS: XSS ok.
  82.                         } else {
  83.                             printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail ); // PHPCS: XSS ok.
  84.                         }
  85.                         ?>
  86.                         </td>
  87.  
  88.                         <td class="product-name" data-title="<?php esc_attr_e( 'Product', 'woocommerce' ); ?>">
  89.                         <?php
  90.                         if ( ! $product_permalink ) {
  91.                             echo wp_kses_post( $product_name . '&nbsp;' );
  92.                         } else {
  93.                             /**
  94.                              * This filter is documented above.
  95.                              *
  96.                              * @since 2.1.0
  97.                              */
  98.                             echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $_product->get_name() ), $cart_item, $cart_item_key ) );
  99.                         }
  100.  
  101.                         do_action( 'woocommerce_after_cart_item_name', $cart_item, $cart_item_key );
  102.  
  103.                         // Meta data.
  104.                         echo wc_get_formatted_cart_item_data( $cart_item ); // PHPCS: XSS ok.
  105.  
  106.                         // Backorder notification.
  107.                         if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) {
  108.                             echo wp_kses_post( apply_filters( 'woocommerce_cart_item_backorder_notification', '<p class="backorder_notification">' . esc_html__( 'Available on backorder', 'woocommerce' ) . '</p>', $product_id ) );
  109.                         }
  110.                         ?>
  111.                         </td>
  112.  
  113.                         <td class="product-price" data-title="<?php esc_attr_e( 'Price', 'woocommerce' ); ?>">
  114.                             <?php
  115.                                 echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); // PHPCS: XSS ok.
  116.                             ?>
  117.                         </td>
  118.  
  119.                         <td class="product-quantity" data-title="<?php esc_attr_e( 'Quantity', 'woocommerce' ); ?>">
  120.                         <?php
  121.                         if ( $_product->is_sold_individually() ) {
  122.                             $min_quantity = 1;
  123.                             $max_quantity = 1;
  124.                         } else {
  125.                             $min_quantity = 0;
  126.                             $max_quantity = $_product->get_max_purchase_quantity();
  127.                         }
  128.  
  129.                         $product_quantity = woocommerce_quantity_input(
  130.                             array(
  131.                                 'input_name'   => "cart[{$cart_item_key}][qty]",
  132.                                 'input_value'  => $cart_item['quantity'],
  133.                                 'max_value'    => $max_quantity,
  134.                                 'min_value'    => $min_quantity,
  135.                                 'product_name' => $product_name,
  136.                             ),
  137.                             $_product,
  138.                             false
  139.                         );
  140.  
  141.                         echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item ); // PHPCS: XSS ok.
  142.                         ?>
  143.                         </td>
  144.  
  145.                         <td class="product-subtotal" data-title="<?php esc_attr_e( 'Subtotal', 'woocommerce' ); ?>">
  146.                             <?php
  147.                                 echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // PHPCS: XSS ok.
  148.                             ?>
  149.                         </td>
  150.                     </tr>
  151.                     <?php
  152.                 }
  153.                 do_action( 'woocommerce/cart_loop/end', $cart_item );
  154.             }
  155.             ?>
  156.  
  157.             <?php do_action( 'woocommerce_cart_contents' ); ?>
  158.  
  159.             <tr>
  160.                 <td colspan="6" class="actions">
  161.  
  162.                     <?php if ( wc_coupons_enabled() ) { ?>
  163.                         <div class="coupon">
  164.                             <label for="coupon_code" class="screen-reader-text"><?php esc_html_e( 'Coupon:', 'woocommerce' ); ?></label> <input type="text" name="coupon_code" class="input-text" id="coupon_code" value="" placeholder="<?php esc_attr_e( 'Coupon code', 'woocommerce' ); ?>" /> <button type="submit" class="button<?php echo esc_attr( wc_wp_theme_get_element_class_name( 'button' ) ? ' ' . wc_wp_theme_get_element_class_name( 'button' ) : '' ); ?>" name="apply_coupon" value="<?php esc_attr_e( 'Apply coupon', 'woocommerce' ); ?>"><?php esc_html_e( 'Apply coupon', 'woocommerce' ); ?></button>
  165.                             <?php do_action( 'woocommerce_cart_coupon' ); ?>
  166.                         </div>
  167.                     <?php } ?>
  168.  
  169.                     <button type="submit" class="button<?php echo esc_attr( wc_wp_theme_get_element_class_name( 'button' ) ? ' ' . wc_wp_theme_get_element_class_name( 'button' ) : '' ); ?>" name="update_cart" value="<?php esc_attr_e( 'Update cart', 'woocommerce' ); ?>"><?php esc_html_e( 'Update cart', 'woocommerce' ); ?></button>
  170.  
  171.                     <?php do_action( 'woocommerce_cart_actions' ); ?>
  172.  
  173.                     <?php wp_nonce_field( 'woocommerce-cart', 'woocommerce-cart-nonce' ); ?>
  174.                 </td>
  175.             </tr>
  176.  
  177.             <?php do_action( 'woocommerce_after_cart_contents' ); ?>
  178.         </tbody>
  179.     </table>
  180.     <?php do_action( 'woocommerce_after_cart_table' ); ?>
  181. </form>
  182.  
  183. <?php do_action( 'woocommerce_before_cart_collaterals' ); ?>
  184.  
  185. <div class="cart-collaterals">
  186.     <?php
  187.         /**
  188.          * Cart collaterals hook.
  189.          *
  190.          * @hooked woocommerce_cross_sell_display
  191.          * @hooked woocommerce_cart_totals - 10
  192.          */
  193.         do_action( 'woocommerce_cart_collaterals' );
  194.     ?>
  195. </div>
  196.  
  197. <?php do_action( 'woocommerce_after_cart' ); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement