cart.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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.3.0
  17. */
  18. if ( ! defined( 'ABSPATH' ) ) {
  19. exit;
  20. }
  21. wc_print_notices();
  22. do_action( 'woocommerce_before_cart' ); ?>
  23. <form class="woocommerce-cart-form" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">
  24. <div class="row">
  25. <div class="vamtam-grid grid-2-3">
  26. <?php do_action( 'woocommerce_before_cart_table' ); ?>
  27. <table class="shop_table shop_table_responsive cart woocommerce-cart-form__contents" cellspacing="0">
  28. <thead>
  29. <tr>
  30. <th class="product-thumbnail">&nbsp;</th>
  31. <th class="product-name"><?php esc_html_e( 'Product', 'vamtam-consulting' ); ?></th>
  32. <th class="product-price"><?php esc_html_e( 'Price', 'vamtam-consulting' ); ?></th>
  33. <th class="product-quantity"><?php esc_html_e( 'Quantity', 'vamtam-consulting' ); ?></th>
  34. <th class="product-subtotal"><?php esc_html_e( 'Total', 'vamtam-consulting' ); ?></th>
  35. <th class="product-remove">&nbsp;</th>
  36. </tr>
  37. </thead>
  38. <tbody>
  39. <?php do_action( 'woocommerce_before_cart_contents' ); ?>
  40. <?php
  41. foreach ( WC()->cart->get_cart() as $cart_item_key => $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. if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
  45. $product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key );
  46. ?>
  47. <tr class="woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
  48. <td class="product-thumbnail">
  49. <?php
  50. $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
  51. if ( ! $product_permalink ) {
  52. echo wp_kses_post( $thumbnail );
  53. } else {
  54. printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), wp_kses_post( $thumbnail ) );
  55. }
  56. ?>
  57. </td>
  58. <td class="product-name" data-title="<?php esc_attr_e( 'Product', 'vamtam-consulting' ); ?>">
  59. <?php
  60. if ( ! $product_permalink ) {
  61. echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . '&nbsp;' );
  62. } else {
  63. 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 ) );
  64. }
  65. // Meta data
  66. echo wc_get_formatted_cart_item_data( $cart_item ); // xss ok
  67. // Backorder notification
  68. if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) {
  69. echo '<p class="backorder_notification">' . esc_html__( 'Available on backorder', 'vamtam-consulting' ) . '</p>';
  70. }
  71. ?>
  72. </td>
  73. <td class="product-price" data-title="<?php esc_attr_e( 'Price', 'vamtam-consulting' ); ?>">
  74. <?php
  75. echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); // xss ok
  76. ?>
  77. </td>
  78. <td class="product-quantity" data-title="<?php esc_attr_e( 'Quantity', 'vamtam-consulting' ); ?>">
  79. <?php
  80. if ( $_product->is_sold_individually() ) {
  81. $product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
  82. } else {
  83. $product_quantity = woocommerce_quantity_input( array(
  84. 'input_name' => "cart[{$cart_item_key}][qty]",
  85. 'input_value' => $cart_item['quantity'],
  86. 'max_value' => $_product->get_max_purchase_quantity(),
  87. 'min_value' => '0',
  88. 'product_name' => $_product->get_name(),
  89. ), $_product, false );
  90. }
  91. echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item ); // xss ok
  92. ?>
  93. </td>
  94. <td class="product-subtotal" data-title="<?php esc_attr_e( 'Total', 'vamtam-consulting' ); ?>">
  95. <?php
  96. echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // xss ok
  97. ?>
  98. </td>
  99. <td class="product-remove">
  100. <?php
  101. echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf( // xss ok
  102. '<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">&times;</a>',
  103. esc_url( wc_get_cart_remove_url( $cart_item_key ) ),
  104. __( 'Remove this item', 'vamtam-consulting' ),
  105. esc_attr( $product_id ),
  106. esc_attr( $_product->get_sku() )
  107. ), $cart_item_key );
  108. ?>
  109. </td>
  110. </tr>
  111. <?php
  112. }
  113. }
  114. ?>
  115. </tbody>
  116. </table>
  117. <?php do_action( 'woocommerce_after_cart_table' ); ?>
  118. </div>
  119. <div class="vamtam-grid grid-1-3">
  120. <div class="cart-collaterals">
  121. <?php
  122. /**
  123. * woocommerce_cart_collaterals hook.
  124. *
  125. * @hooked woocommerce_cross_sell_display
  126. * @hooked woocommerce_cart_totals - 10
  127. */
  128. do_action( 'woocommerce_cart_collaterals' );
  129. ?>
  130. <div class="cart-contents">
  131. <?php do_action( 'woocommerce_cart_contents' ); ?>
  132. <?php if ( WC()->cart->coupons_enabled() ) { ?>
  133. <div class="coupon">
  134. <label for="coupon_code"><?php esc_html_e( 'Coupon', 'vamtam-consulting' ); ?>:</label>
  135. <input type="text" name="coupon_code" class="input-text" id="coupon_code" value="" placeholder="<?php esc_attr_e( 'Coupon code', 'vamtam-consulting' ); ?>" />
  136. <input type="submit" name="apply_coupon" value="<?php esc_attr_e( 'Apply Coupon', 'vamtam-consulting' ); ?>" />
  137. <?php do_action( 'woocommerce_cart_coupon' ); ?>
  138. </div>
  139. <?php } ?>
  140. <?php wp_nonce_field( 'woocommerce-cart' ); ?>
  141. <?php do_action( 'woocommerce_after_cart_contents' ); ?>
  142. </div>
  143. </div>
  144. </div>
  145. </div>
  146. </form>
  147. <?php do_action( 'woocommerce_after_cart' ); ?>