Advertisement
nshelper

Untitled

Sep 9th, 2022
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.53 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://docs.woocommerce.com/document/template-structure/
  14.  * @package WooCommerce\Templates
  15.  * @version 3.8.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">&nbsp;</th>
  29.                 <th class="product-thumbnail">&nbsp;</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.                
  42.                 do_action( 'woocommerce/cart_loop/start', $cart_item );
  43.                
  44.                 $_product   = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
  45.                 $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
  46.  
  47.                 if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
  48.                     $product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key );
  49.                     ?>
  50.                     <tr class="woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
  51.  
  52.                         <td class="product-remove">
  53.                             <?php
  54.                                 echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  55.                                     'woocommerce_cart_item_remove_link',
  56.                                     sprintf(
  57.                                         '<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">&times;</a>',
  58.                                         esc_url( wc_get_cart_remove_url( $cart_item_key ) ),
  59.                                         esc_html__( 'Remove this item', 'woocommerce' ),
  60.                                         esc_attr( $product_id ),
  61.                                         esc_attr( $_product->get_sku() )
  62.                                     ),
  63.                                     $cart_item_key
  64.                                 );
  65.                             ?>
  66.                         </td>
  67.  
  68.                         <td class="product-thumbnail">
  69.                         <?php
  70.                         $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
  71.  
  72.                         if ( ! $product_permalink ) {
  73.                             echo $thumbnail; // PHPCS: XSS ok.
  74.                         } else {
  75.                             printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail ); // PHPCS: XSS ok.
  76.                         }
  77.                         ?>
  78.                         </td>
  79.  
  80.                         <td class="product-name" data-title="<?php esc_attr_e( 'Product', 'woocommerce' ); ?>">
  81.                         <?php
  82.                         if ( ! $product_permalink ) {
  83.                             echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . '&nbsp;' );
  84.                         } else {
  85.                             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 ) );
  86.                         }
  87.  
  88.                         do_action( 'woocommerce_after_cart_item_name', $cart_item, $cart_item_key );
  89.  
  90.                         // Meta data.
  91.                         echo wc_get_formatted_cart_item_data( $cart_item ); // PHPCS: XSS ok.
  92.  
  93.                         // Backorder notification.
  94.                         if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) {
  95.                             echo wp_kses_post( apply_filters( 'woocommerce_cart_item_backorder_notification', '<p class="backorder_notification">' . esc_html__( 'Available on backorder', 'woocommerce' ) . '</p>', $product_id ) );
  96.                         }
  97.                         ?>
  98.                         </td>
  99.  
  100.                         <td class="product-price" data-title="<?php esc_attr_e( 'Price', 'woocommerce' ); ?>">
  101.                             <?php
  102.                                 echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); // PHPCS: XSS ok.
  103.                             ?>
  104.                         </td>
  105.  
  106.                         <td class="product-quantity" data-title="<?php esc_attr_e( 'Quantity', 'woocommerce' ); ?>">
  107.                         <?php
  108.                         if ( $_product->is_sold_individually() ) {
  109.                             $product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
  110.                         } else {
  111.                             $product_quantity = woocommerce_quantity_input(
  112.                                 array(
  113.                                     'input_name'   => "cart[{$cart_item_key}][qty]",
  114.                                     'input_value'  => $cart_item['quantity'],
  115.                                     'max_value'    => $_product->get_max_purchase_quantity(),
  116.                                     'min_value'    => '0',
  117.                                     'product_name' => $_product->get_name(),
  118.                                 ),
  119.                                 $_product,
  120.                                 false
  121.                             );
  122.                         }
  123.  
  124.                         echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item ); // PHPCS: XSS ok.
  125.                         ?>
  126.                         </td>
  127.  
  128.                         <td class="product-subtotal" data-title="<?php esc_attr_e( 'Subtotal', 'woocommerce' ); ?>">
  129.                             <?php
  130.                                 echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // PHPCS: XSS ok.
  131.                             ?>
  132.                         </td>
  133.                     </tr>
  134.                     <?php
  135.                 }
  136.                
  137.                 do_action( 'woocommerce/cart_loop/end', $cart_item);
  138.             }
  139.             ?>
  140.  
  141.             <?php do_action( 'woocommerce_cart_contents' ); ?>
  142.  
  143.             <tr>
  144.                 <td colspan="6" class="actions">
  145.  
  146.                     <?php if ( wc_coupons_enabled() ) { ?>
  147.                         <div class="coupon">
  148.                             <label for="coupon_code"><?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" name="apply_coupon" value="<?php esc_attr_e( 'Apply coupon', 'woocommerce' ); ?>"><?php esc_attr_e( 'Apply coupon', 'woocommerce' ); ?></button>
  149.                             <?php do_action( 'woocommerce_cart_coupon' ); ?>
  150.                         </div>
  151.                     <?php } ?>
  152.  
  153.                     <button type="submit" class="button" name="update_cart" value="<?php esc_attr_e( 'Update cart', 'woocommerce' ); ?>"><?php esc_html_e( 'Update cart', 'woocommerce' ); ?></button>
  154.  
  155.                     <?php do_action( 'woocommerce_cart_actions' ); ?>
  156.  
  157.                     <?php wp_nonce_field( 'woocommerce-cart', 'woocommerce-cart-nonce' ); ?>
  158.                 </td>
  159.             </tr>
  160.  
  161.             <?php do_action( 'woocommerce_after_cart_contents' ); ?>
  162.         </tbody>
  163.     </table>
  164.     <?php do_action( 'woocommerce_after_cart_table' ); ?>
  165. </form>
  166.  
  167. <?php do_action( 'woocommerce_before_cart_collaterals' ); ?>
  168.  
  169. <div class="cart-collaterals">
  170.     <?php
  171.         /**
  172.          * Cart collaterals hook.
  173.          *
  174.          * @hooked woocommerce_cross_sell_display
  175.          * @hooked woocommerce_cart_totals - 10
  176.          */
  177.         do_action( 'woocommerce_cart_collaterals' );
  178.     ?>
  179. </div>
  180.  
  181. <?php do_action( 'woocommerce_after_cart' ); ?>
  182.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement