cart-empty.php
9 years ago
cart-item-data.php
9 years ago
cart-shipping.php
9 years ago
cart-totals.php
9 years ago
cart.php
9 years ago
cross-sells.php
9 years ago
mini-cart.php
9 years ago
proceed-to-checkout-button.php
9 years ago
shipping-calculator.php
9 years ago
cart.php
169 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 | * @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 | <table class="shop_table shop_table_responsive cart woocommerce-cart-form__contents" cellspacing="0"> |
| 31 | <thead> |
| 32 | <tr> |
| 33 | <th class="product-remove"> </th> |
| 34 | <th class="product-thumbnail"> </th> |
| 35 | <th class="product-name"><?php _e( 'Product', 'woocommerce' ); ?></th> |
| 36 | <th class="product-price"><?php _e( 'Price', 'woocommerce' ); ?></th> |
| 37 | <th class="product-quantity"><?php _e( 'Quantity', 'woocommerce' ); ?></th> |
| 38 | <th class="product-subtotal"><?php _e( 'Total', 'woocommerce' ); ?></th> |
| 39 | </tr> |
| 40 | </thead> |
| 41 | <tbody> |
| 42 | <?php do_action( 'woocommerce_before_cart_contents' ); ?> |
| 43 | |
| 44 | <?php |
| 45 | foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { |
| 46 | $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); |
| 47 | $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key ); |
| 48 | |
| 49 | if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key ) ) { |
| 50 | $product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key ); |
| 51 | ?> |
| 52 | <tr class="woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>"> |
| 53 | |
| 54 | <td class="product-remove"> |
| 55 | <?php |
| 56 | echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf( |
| 57 | '<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">×</a>', |
| 58 | esc_url( WC()->cart->get_remove_url( $cart_item_key ) ), |
| 59 | __( 'Remove this item', 'woocommerce' ), |
| 60 | esc_attr( $product_id ), |
| 61 | esc_attr( $_product->get_sku() ) |
| 62 | ), $cart_item_key ); |
| 63 | ?> |
| 64 | </td> |
| 65 | |
| 66 | <td class="product-thumbnail"> |
| 67 | <?php |
| 68 | $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key ); |
| 69 | |
| 70 | if ( ! $product_permalink ) { |
| 71 | echo $thumbnail; |
| 72 | } else { |
| 73 | printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail ); |
| 74 | } |
| 75 | ?> |
| 76 | </td> |
| 77 | |
| 78 | <td class="product-name" data-title="<?php esc_attr_e( 'Product', 'woocommerce' ); ?>"> |
| 79 | <?php |
| 80 | if ( ! $product_permalink ) { |
| 81 | echo apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . ' '; |
| 82 | } else { |
| 83 | echo apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $_product->get_name() ), $cart_item, $cart_item_key ); |
| 84 | } |
| 85 | |
| 86 | // Meta data |
| 87 | echo WC()->cart->get_item_data( $cart_item ); |
| 88 | |
| 89 | // Backorder notification |
| 90 | if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) { |
| 91 | echo '<p class="backorder_notification">' . esc_html__( 'Available on backorder', 'woocommerce' ) . '</p>'; |
| 92 | } |
| 93 | ?> |
| 94 | </td> |
| 95 | |
| 96 | <td class="product-price" data-title="<?php esc_attr_e( 'Price', 'woocommerce' ); ?>"> |
| 97 | <?php |
| 98 | echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); |
| 99 | ?> |
| 100 | </td> |
| 101 | |
| 102 | <td class="product-quantity" data-title="<?php esc_attr_e( 'Quantity', 'woocommerce' ); ?>"> |
| 103 | <?php |
| 104 | if ( $_product->is_sold_individually() ) { |
| 105 | $product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key ); |
| 106 | } else { |
| 107 | $product_quantity = woocommerce_quantity_input( array( |
| 108 | 'input_name' => "cart[{$cart_item_key}][qty]", |
| 109 | 'input_value' => $cart_item['quantity'], |
| 110 | 'max_value' => $_product->get_max_purchase_quantity(), |
| 111 | 'min_value' => '0', |
| 112 | ), $_product, false ); |
| 113 | } |
| 114 | |
| 115 | echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item ); |
| 116 | ?> |
| 117 | </td> |
| 118 | |
| 119 | <td class="product-subtotal" data-title="<?php esc_attr_e( 'Total', 'woocommerce' ); ?>"> |
| 120 | <?php |
| 121 | echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); |
| 122 | ?> |
| 123 | </td> |
| 124 | </tr> |
| 125 | <?php |
| 126 | } |
| 127 | } |
| 128 | ?> |
| 129 | |
| 130 | <?php do_action( 'woocommerce_cart_contents' ); ?> |
| 131 | |
| 132 | <tr> |
| 133 | <td colspan="6" class="actions"> |
| 134 | |
| 135 | <?php if ( wc_coupons_enabled() ) { ?> |
| 136 | <div class="coupon"> |
| 137 | <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' ); ?>" /> |
| 138 | <?php do_action( 'woocommerce_cart_coupon' ); ?> |
| 139 | </div> |
| 140 | <?php } ?> |
| 141 | |
| 142 | <input type="submit" class="button" name="update_cart" value="<?php esc_attr_e( 'Update cart', 'woocommerce' ); ?>" /> |
| 143 | |
| 144 | <?php do_action( 'woocommerce_cart_actions' ); ?> |
| 145 | |
| 146 | <?php wp_nonce_field( 'woocommerce-cart' ); ?> |
| 147 | </td> |
| 148 | </tr> |
| 149 | |
| 150 | <?php do_action( 'woocommerce_after_cart_contents' ); ?> |
| 151 | </tbody> |
| 152 | </table> |
| 153 | <?php do_action( 'woocommerce_after_cart_table' ); ?> |
| 154 | </form> |
| 155 | |
| 156 | <div class="cart-collaterals"> |
| 157 | <?php |
| 158 | /** |
| 159 | * woocommerce_cart_collaterals hook. |
| 160 | * |
| 161 | * @hooked woocommerce_cross_sell_display |
| 162 | * @hooked woocommerce_cart_totals - 10 |
| 163 | */ |
| 164 | do_action( 'woocommerce_cart_collaterals' ); |
| 165 | ?> |
| 166 | </div> |
| 167 | |
| 168 | <?php do_action( 'woocommerce_after_cart' ); ?> |
| 169 |