cart-empty.php
5 years ago
cart-item-data.php
5 years ago
cart-shipping.php
5 years ago
cart-totals.php
5 years ago
cart.php
3 years ago
cross-sells.php
5 years ago
mini-cart.php
5 years ago
proceed-to-checkout-button.php
5 years ago
shipping-calculator.php
3 years ago
cart.php
177 lines
| 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"><span class="screen-reader-text"><?php esc_html_e( 'Remove item', 'woocommerce' ); ?></span></th> |
| 29 | <th class="product-thumbnail"><span class="screen-reader-text"><?php esc_html_e( 'Thumbnail image', 'woocommerce' ); ?></span></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 | $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); |
| 42 | $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key ); |
| 43 | |
| 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 | |
| 49 | <td class="product-remove"> |
| 50 | <?php |
| 51 | echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 52 | 'woocommerce_cart_item_remove_link', |
| 53 | sprintf( |
| 54 | '<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">×</a>', |
| 55 | esc_url( wc_get_cart_remove_url( $cart_item_key ) ), |
| 56 | esc_html__( 'Remove this item', 'woocommerce' ), |
| 57 | esc_attr( $product_id ), |
| 58 | esc_attr( $_product->get_sku() ) |
| 59 | ), |
| 60 | $cart_item_key |
| 61 | ); |
| 62 | ?> |
| 63 | </td> |
| 64 | |
| 65 | <td class="product-thumbnail"> |
| 66 | <?php |
| 67 | $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key ); |
| 68 | |
| 69 | if ( ! $product_permalink ) { |
| 70 | echo $thumbnail; // PHPCS: XSS ok. |
| 71 | } else { |
| 72 | printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail ); // PHPCS: XSS ok. |
| 73 | } |
| 74 | ?> |
| 75 | </td> |
| 76 | |
| 77 | <td class="product-name" data-title="<?php esc_attr_e( 'Product', 'woocommerce' ); ?>"> |
| 78 | <?php |
| 79 | if ( ! $product_permalink ) { |
| 80 | echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . ' ' ); |
| 81 | } else { |
| 82 | 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 ) ); |
| 83 | } |
| 84 | |
| 85 | do_action( 'woocommerce_after_cart_item_name', $cart_item, $cart_item_key ); |
| 86 | |
| 87 | // Meta data. |
| 88 | echo wc_get_formatted_cart_item_data( $cart_item ); // PHPCS: XSS ok. |
| 89 | |
| 90 | // Backorder notification. |
| 91 | if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) { |
| 92 | echo wp_kses_post( apply_filters( 'woocommerce_cart_item_backorder_notification', '<p class="backorder_notification">' . esc_html__( 'Available on backorder', 'woocommerce' ) . '</p>', $product_id ) ); |
| 93 | } |
| 94 | ?> |
| 95 | </td> |
| 96 | |
| 97 | <td class="product-price" data-title="<?php esc_attr_e( 'Price', 'woocommerce' ); ?>"> |
| 98 | <?php |
| 99 | echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); // PHPCS: XSS ok. |
| 100 | ?> |
| 101 | </td> |
| 102 | |
| 103 | <td class="product-quantity" data-title="<?php esc_attr_e( 'Quantity', 'woocommerce' ); ?>"> |
| 104 | <?php |
| 105 | if ( $_product->is_sold_individually() ) { |
| 106 | $product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key ); |
| 107 | } else { |
| 108 | $product_quantity = woocommerce_quantity_input( |
| 109 | array( |
| 110 | 'input_name' => "cart[{$cart_item_key}][qty]", |
| 111 | 'input_value' => $cart_item['quantity'], |
| 112 | 'max_value' => $_product->get_max_purchase_quantity(), |
| 113 | 'min_value' => '0', |
| 114 | 'product_name' => $_product->get_name(), |
| 115 | ), |
| 116 | $_product, |
| 117 | false |
| 118 | ); |
| 119 | } |
| 120 | |
| 121 | echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item ); // PHPCS: XSS ok. |
| 122 | ?> |
| 123 | </td> |
| 124 | |
| 125 | <td class="product-subtotal" data-title="<?php esc_attr_e( 'Subtotal', 'woocommerce' ); ?>"> |
| 126 | <?php |
| 127 | echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // PHPCS: XSS ok. |
| 128 | ?> |
| 129 | </td> |
| 130 | </tr> |
| 131 | <?php |
| 132 | } |
| 133 | } |
| 134 | ?> |
| 135 | |
| 136 | <?php do_action( 'woocommerce_cart_contents' ); ?> |
| 137 | |
| 138 | <tr> |
| 139 | <td colspan="6" class="actions"> |
| 140 | |
| 141 | <?php if ( wc_coupons_enabled() ) { ?> |
| 142 | <div class="coupon"> |
| 143 | <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> |
| 144 | <?php do_action( 'woocommerce_cart_coupon' ); ?> |
| 145 | </div> |
| 146 | <?php } ?> |
| 147 | |
| 148 | <button type="submit" class="button" name="update_cart" value="<?php esc_attr_e( 'Update cart', 'woocommerce' ); ?>"><?php esc_html_e( 'Update cart', 'woocommerce' ); ?></button> |
| 149 | |
| 150 | <?php do_action( 'woocommerce_cart_actions' ); ?> |
| 151 | |
| 152 | <?php wp_nonce_field( 'woocommerce-cart', 'woocommerce-cart-nonce' ); ?> |
| 153 | </td> |
| 154 | </tr> |
| 155 | |
| 156 | <?php do_action( 'woocommerce_after_cart_contents' ); ?> |
| 157 | </tbody> |
| 158 | </table> |
| 159 | <?php do_action( 'woocommerce_after_cart_table' ); ?> |
| 160 | </form> |
| 161 | |
| 162 | <?php do_action( 'woocommerce_before_cart_collaterals' ); ?> |
| 163 | |
| 164 | <div class="cart-collaterals"> |
| 165 | <?php |
| 166 | /** |
| 167 | * Cart collaterals hook. |
| 168 | * |
| 169 | * @hooked woocommerce_cross_sell_display |
| 170 | * @hooked woocommerce_cart_totals - 10 |
| 171 | */ |
| 172 | do_action( 'woocommerce_cart_collaterals' ); |
| 173 | ?> |
| 174 | </div> |
| 175 | |
| 176 | <?php do_action( 'woocommerce_after_cart' ); ?> |
| 177 |