Advertisement
Guest User

Untitled

a guest
Jul 11th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.65 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.4.0
  16.  */
  17.  
  18. defined( 'ABSPATH' ) || exit;
  19.  
  20. wc_print_notices();
  21.  
  22. do_action( 'woocommerce_before_cart' ); ?>
  23.  
  24. <form class="woocommerce-cart-form" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">
  25.     <?php do_action( 'woocommerce_before_cart_table' ); ?>
  26.    
  27.     <table class="shop_table shop_table_responsive cart woocommerce-cart-form__contents" cellspacing="0">
  28.         <thead>
  29.             <tr>
  30.                 <th class="product-remove">&nbsp;</th>
  31.                 <th class="product-thumbnail">&nbsp;</th>
  32.                 <th class="product-name"><?php esc_html_e( 'Product', 'woocommerce' ); ?></th>
  33.                 <th class="product-price"><?php esc_html_e( 'Price', 'woocommerce' ); ?></th>
  34.                 <th class="product-quantity"><?php esc_html_e( 'Quantity', 'woocommerce' ); ?></th>
  35.                 <th class="product-subtotal"><?php esc_html_e( 'Total', 'woocommerce' ); ?></th>
  36.             </tr>
  37.         </thead>
  38.         <tbody>
  39.             <?php do_action( 'woocommerce_before_cart_contents' ); ?>
  40.            
  41.             <?php
  42.             foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
  43.                 $_product   = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
  44.                 $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
  45.                
  46.                 if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
  47.                     $product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key );
  48.                     ?>
  49.                     <tr class="woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
  50.                        
  51.                         <td class="product-remove">
  52.                             <?php
  53.                                 // @codingStandardsIgnoreLine
  54.                                 echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf(
  55.                                     '<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">&times;</a>',
  56.                                     esc_url( wc_get_cart_remove_url( $cart_item_key ) ),
  57.                                     __( 'Remove this item', 'woocommerce' ),
  58.                                     esc_attr( $product_id ),
  59.                                     esc_attr( $_product->get_sku() )
  60.                                 ), $cart_item_key );
  61.                             ?>
  62.                         </td>
  63.                        
  64.                         <td class="product-thumbnail">
  65.                         <?php
  66.                         $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
  67.  
  68.                         if ( ! $product_permalink ) {
  69.                             echo wp_kses_post( $thumbnail );
  70.                         } else {
  71.                             printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), wp_kses_post( $thumbnail ) );
  72.                         }
  73.                         ?>
  74.                         </td>
  75.                        
  76.                         <td class="product-name" data-title="<?php esc_attr_e( 'Product', 'woocommerce' ); ?>">
  77.                             <?php
  78.                            
  79.                                 /*** Our code modification inside Woo template - begin ***/
  80.                                
  81.                                 if ( version_compare( WOOCOMMERCE_VERSION, '3.0' ) >= 0 ) {
  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.                                 } else {
  88.                                     if ( ! $product_permalink ) {
  89.                                         echo apply_filters( 'woocommerce_cart_item_name', $_product->get_title(), $cart_item, $cart_item_key ) . '&nbsp;';
  90.                                     } else {
  91.                                         echo apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $_product->get_title() ), $cart_item, $cart_item_key );
  92.                                     }
  93.                                 }
  94.                                
  95.                                 /*** Our code modification inside Woo template - end ***/
  96.                            
  97.                                 // Meta data.
  98.                                 echo wc_get_formatted_cart_item_data( $cart_item ); // PHPCS: XSS ok.
  99.                                
  100.                                 // Backorder notification.
  101.                                 if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) {
  102.                                     echo wp_kses_post( apply_filters( 'woocommerce_cart_item_backorder_notification', '<p class="backorder_notification">' . esc_html__( 'Available on backorder', 'woocommerce' ) . '</p>' ) );
  103.                                 }
  104.                             ?>
  105.                         </td>
  106.                        
  107.                         <td class="product-price" data-title="<?php esc_attr_e( 'Price', 'woocommerce' ); ?>">
  108.                             <?php
  109.                                 echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); // PHPCS: XSS ok.
  110.                             ?>
  111.                         </td>
  112.                        
  113.                         <td class="product-quantity" data-title="<?php esc_attr_e( 'Quantity', 'woocommerce' ); ?>">
  114.                         <?php
  115.                         if ( $_product->is_sold_individually() ) {
  116.                             $product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
  117.                         } else {
  118.                             $product_quantity = woocommerce_quantity_input( array(
  119.                                 'input_name'   => "cart[{$cart_item_key}][qty]",
  120.                                 'input_value'  => $cart_item['quantity'],
  121.                                 'max_value'    => $_product->get_max_purchase_quantity(),
  122.                                 'min_value'    => '0',
  123.                                 'product_name' => $_product->get_name(),
  124.                             ), $_product, false );
  125.                         }
  126.  
  127.                         echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item ); // PHPCS: XSS ok.
  128.                         ?>
  129.                         </td>
  130.                        
  131.                         <td class="product-subtotal" data-title="<?php esc_attr_e( 'Total', 'woocommerce' ); ?>">
  132.                             <?php
  133.                                 echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key );
  134.                             ?>
  135.                         </td>
  136.                     </tr>
  137.                     <?php
  138.                 }
  139.             }
  140.             ?>
  141.            
  142.             <?php do_action( 'woocommerce_cart_contents' ); ?>
  143.            
  144.             <tr>
  145.                 <td colspan="6" class="actions">
  146.                    
  147.                     <?php if ( wc_coupons_enabled() ) { ?>
  148.                         <div class="coupon">
  149.                             <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' ); ?>" /> <input type="submit" class="button" name="apply_coupon" value="<?php esc_attr_e( 'Apply coupon', 'woocommerce' ); ?>" />
  150.                             <?php do_action( 'woocommerce_cart_coupon' ); ?>
  151.                         </div>
  152.                     <?php } ?>
  153.                    
  154.                     <input type="submit" class="button" name="update_cart" value="<?php esc_attr_e( 'Update cart', 'woocommerce' ); ?>" />
  155.                    
  156.                     <?php /*** Our code modification inside Woo template - begin ***/ ?>
  157.                     <?php do_action( 'woocommerce_proceed_to_checkout' ); ?>
  158.                     <?php /*** Our code modification inside Woo template - end ***/ ?>
  159.                    
  160.                     <?php do_action( 'woocommerce_cart_actions' ); ?>
  161.  
  162.                     <?php wp_nonce_field( 'woocommerce-cart', 'woocommerce-cart-nonce' ); ?>
  163.                 </td>
  164.             </tr>
  165.            
  166.             <?php do_action( 'woocommerce_after_cart_contents' ); ?>
  167.         </tbody>
  168.     </table>
  169.     <?php do_action( 'woocommerce_after_cart_table' ); ?>
  170. </form>
  171.  
  172. <div class="cart-collaterals clearfix">
  173.     <?php
  174.         /**
  175.          * woocommerce_cart_collaterals hook.
  176.          *
  177.          * @hooked woocommerce_cross_sell_display
  178.          * @hooked woocommerce_cart_totals - 10
  179.          */
  180.         do_action( 'woocommerce_cart_collaterals' );
  181.     ?>
  182.    
  183.    
  184. </div>
  185.  
  186. <?php do_action( 'woocommerce_after_cart' ); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement