Bez popisu

cart.php 7.2KB

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