Advertisement
rdusnr

Untitled

Oct 4th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.72 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. * @author WooThemes
  15. * @package WooCommerce/Templates
  16. * @version 3.1.0
  17. */
  18.  
  19. if ( ! defined( 'ABSPATH' ) ) {
  20. exit;
  21. }
  22.  
  23. wc_print_notices();
  24.  
  25. do_action( 'woocommerce_before_cart' ); ?>
  26.  
  27. <form class="woocommerce-cart-form" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">
  28. <?php do_action( 'woocommerce_before_cart_table' ); ?>
  29.  
  30. <div class="row">
  31. <div class="col-sm-8">
  32. <table class="shop_table shop_table_responsive cart woocommerce-cart-form__contents" cellspacing="0">
  33. <thead>
  34. <tr>
  35. <th class="product-remove">&nbsp;</th>
  36. <th class="product-thumbnail">&nbsp;</th>
  37. <th class="product-name"><?php _e( 'Product', 'woocommerce' ); ?></th>
  38. <th class="product-price"><?php _e( 'Price', 'woocommerce' ); ?></th>
  39. <th class="product-quantity"><?php _e( 'Quantity', 'woocommerce' ); ?></th>
  40. <th class="product-subtotal"><?php _e( 'Total', 'woocommerce' ); ?></th>
  41. </tr>
  42. </thead>
  43. <tbody>
  44. <?php do_action( 'woocommerce_before_cart_contents' ); ?>
  45.  
  46. <?php
  47. foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
  48. $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
  49. $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
  50.  
  51. if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
  52. $product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key );
  53. ?>
  54. <tr class="woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
  55.  
  56. <td class="product-remove">
  57. <?php
  58. echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf(
  59. '<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">&times;</a>',
  60. esc_url( WC()->cart->get_remove_url( $cart_item_key ) ),
  61. __( 'Remove this item', 'woocommerce' ),
  62. esc_attr( $product_id ),
  63. esc_attr( $_product->get_sku() )
  64. ), $cart_item_key );
  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;
  74. } else {
  75. printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail );
  76. }
  77. ?>
  78. </td>
  79.  
  80. <td class="product-name" data-title="<?php esc_attr_e( 'Product', 'woocommerce' ); ?>">
  81. <?php
  82. if ( version_compare( WOOCOMMERCE_VERSION, '3.0.0' ) >= 0 ) {
  83. $prod_name = $_product->get_name();
  84. } else {
  85. $prod_name = $_product->get_title();
  86. }
  87. if ( ! $product_permalink ) {
  88. echo apply_filters( 'woocommerce_cart_item_name', $prod_name, $cart_item, $cart_item_key ) . '&nbsp;';
  89. } else {
  90. echo apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $prod_name ), $cart_item, $cart_item_key );
  91. }
  92.  
  93. // Meta data
  94. echo WC()->cart->get_item_data( $cart_item );
  95.  
  96. // Backorder notification
  97. if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) {
  98. echo '<p class="backorder_notification">' . esc_html__( 'Available on backorder', 'woocommerce' ) . '</p>';
  99. }
  100. ?>
  101. </td>
  102.  
  103. <td class="product-price" data-title="<?php esc_attr_e( 'Price', 'woocommerce' ); ?>">
  104. <?php
  105. echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key );
  106. ?>
  107. </td>
  108.  
  109. <td class="product-quantity" data-title="<?php esc_attr_e( 'Quantity', 'woocommerce' ); ?>">
  110. <?php
  111. if ( $_product->is_sold_individually() ) {
  112. $product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
  113. } else {
  114. $product_quantity = woocommerce_quantity_input( array(
  115. 'input_name' => "cart[{$cart_item_key}][qty]",
  116. 'input_value' => $cart_item['quantity'],
  117. 'max_value' => $_product->get_max_purchase_quantity(),
  118. 'min_value' => '0',
  119. ), $_product, false );
  120. }
  121.  
  122. echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item );
  123. ?>
  124. </td>
  125.  
  126. <td class="product-subtotal" data-title="<?php esc_attr_e( 'Total', 'woocommerce' ); ?>">
  127. <?php
  128. echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key );
  129. ?>
  130. </td>
  131. </tr>
  132. <?php
  133. }
  134. }
  135. ?>
  136.  
  137. <?php do_action( 'woocommerce_cart_contents' ); ?>
  138.  
  139. <?php do_action( 'woocommerce_after_cart_contents' ); ?>
  140. </tbody>
  141. </table>
  142.  
  143. <?php do_action( 'woocommerce_after_cart_table' ); ?>
  144.  
  145. <div class="cart-collaterals">
  146.  
  147. <?php do_action( 'woocommerce_cart_collaterals' ); ?>
  148.  
  149. </div>
  150.  
  151. </div>
  152.  
  153. <div class="col-sm-4">
  154. <div class="kleo-cart-totals">
  155.  
  156. <div class="totals-wrap">
  157.  
  158. <?php woocommerce_cart_totals(); ?>
  159.  
  160. <input type="submit" class="button" name="update_cart"
  161. value="<?php _e( 'Update cart', 'woocommerce' ); ?>"/>
  162.  
  163. <input type="submit" class="checkout-button button alt wc-forward" name="proceed"
  164. value="<?php _e( 'Proceed to checkout', 'woocommerce' ); ?>"/>
  165.  
  166. <?php if ( version_compare( WOOCOMMERCE_VERSION, '2.3.0', '<' ) ) : ?>
  167. <input type="submit" class="checkout-button button alt wc-forward" name="proceed"
  168. value="<?php _e( 'Proceed to checkout', 'woocommerce' ); ?>"/>
  169. <?php endif; ?>
  170.  
  171. </div>
  172. <?php if ( version_compare( WOOCOMMERCE_VERSION, '2.3.0', '<' ) ) : ?>
  173.  
  174. <?php do_action( 'woocommerce_proceed_to_checkout' ); ?>
  175.  
  176. <?php else : ?>
  177.  
  178. <?php do_action( 'woocommerce_cart_actions' ); ?>
  179.  
  180. <?php endif; ?>
  181.  
  182. <?php wp_nonce_field( 'woocommerce-cart' ); ?>
  183.  
  184. <?php if ( wc_coupons_enabled() ) { ?>
  185. <div class="coupon">
  186. <label for="coupon_code"><?php _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' ); ?>" />
  187. <?php do_action( 'woocommerce_cart_coupon' ); ?>
  188. </div>
  189. <?php } ?>
  190.  
  191. <?php if ( version_compare( WOOCOMMERCE_VERSION, '2.3.0', '<' ) ) : ?>
  192.  
  193. <?php woocommerce_shipping_calculator(); ?>
  194.  
  195. <?php endif; ?>
  196.  
  197. </div>
  198. </div>
  199. </div>
  200.  
  201. </form>
  202.  
  203. <?php do_action( 'woocommerce_after_cart' ); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement