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
mini-cart.php
84 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Mini-cart |
| 4 | * |
| 5 | * Contains the markup for the mini-cart, used by the cart widget. |
| 6 | * |
| 7 | * This template can be overridden by copying it to yourtheme/woocommerce/cart/mini-cart.php. |
| 8 | * |
| 9 | * HOWEVER, on occasion WooCommerce will need to update template files and you |
| 10 | * (the theme developer) will need to copy the new files to your theme to |
| 11 | * maintain compatibility. We try to do this as little as possible, but it does |
| 12 | * happen. When this occurs the version of the template file will be bumped and |
| 13 | * the readme will list any important changes. |
| 14 | * |
| 15 | * @see https://docs.woocommerce.com/document/template-structure/ |
| 16 | * @author WooThemes |
| 17 | * @package WooCommerce/Templates |
| 18 | * @version 3.1.0 |
| 19 | */ |
| 20 | if ( ! defined( 'ABSPATH' ) ) { |
| 21 | exit; |
| 22 | } |
| 23 | |
| 24 | do_action( 'woocommerce_before_mini_cart' ); ?> |
| 25 | |
| 26 | <?php if ( ! WC()->cart->is_empty() ) : ?> |
| 27 | |
| 28 | <ul class="woocommerce-mini-cart cart_list product_list_widget <?php echo esc_attr( $args['list_class'] ); ?>"> |
| 29 | <?php |
| 30 | do_action( 'woocommerce_before_mini_cart_contents' ); |
| 31 | |
| 32 | foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { |
| 33 | $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); |
| 34 | $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key ); |
| 35 | |
| 36 | if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_widget_cart_item_visible', true, $cart_item, $cart_item_key ) ) { |
| 37 | $product_name = apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ); |
| 38 | $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key ); |
| 39 | $product_price = apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); |
| 40 | $product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key ); |
| 41 | ?> |
| 42 | <li class="woocommerce-mini-cart-item <?php echo esc_attr( apply_filters( 'woocommerce_mini_cart_item_class', 'mini_cart_item', $cart_item, $cart_item_key ) ); ?>"> |
| 43 | <?php |
| 44 | echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf( |
| 45 | '<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">×</a>', |
| 46 | esc_url( WC()->cart->get_remove_url( $cart_item_key ) ), |
| 47 | __( 'Remove this item', 'woocommerce' ), |
| 48 | esc_attr( $product_id ), |
| 49 | esc_attr( $_product->get_sku() ) |
| 50 | ), $cart_item_key ); |
| 51 | ?> |
| 52 | <?php if ( ! $_product->is_visible() ) : ?> |
| 53 | <?php echo str_replace( array( 'http:', 'https:' ), '', $thumbnail ) . $product_name . ' '; ?> |
| 54 | <?php else : ?> |
| 55 | <a href="<?php echo esc_url( $product_permalink ); ?>"> |
| 56 | <?php echo str_replace( array( 'http:', 'https:' ), '', $thumbnail ) . $product_name . ' '; ?> |
| 57 | </a> |
| 58 | <?php endif; ?> |
| 59 | <?php echo WC()->cart->get_item_data( $cart_item ); ?> |
| 60 | |
| 61 | <?php echo apply_filters( 'woocommerce_widget_cart_item_quantity', '<span class="quantity">' . sprintf( '%s × %s', $cart_item['quantity'], $product_price ) . '</span>', $cart_item, $cart_item_key ); ?> |
| 62 | </li> |
| 63 | <?php |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | do_action( 'woocommerce_mini_cart_contents' ); |
| 68 | ?> |
| 69 | </ul> |
| 70 | |
| 71 | <p class="woocommerce-mini-cart__total total"><strong><?php _e( 'Subtotal', 'woocommerce' ); ?>:</strong> <?php echo WC()->cart->get_cart_subtotal(); ?></p> |
| 72 | |
| 73 | <?php do_action( 'woocommerce_widget_shopping_cart_before_buttons' ); ?> |
| 74 | |
| 75 | <p class="woocommerce-mini-cart__buttons buttons"><?php do_action( 'woocommerce_widget_shopping_cart_buttons' ); ?></p> |
| 76 | |
| 77 | <?php else : ?> |
| 78 | |
| 79 | <p class="woocommerce-mini-cart__empty-message"><?php _e( 'No products in the cart.', 'woocommerce' ); ?></p> |
| 80 | |
| 81 | <?php endif; ?> |
| 82 | |
| 83 | <?php do_action( 'woocommerce_after_mini_cart' ); ?> |
| 84 |