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
5 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
5 years ago
mini-cart.php
97 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 | * @package WooCommerce\Templates |
| 17 | * @version 3.7.0 |
| 18 | */ |
| 19 | |
| 20 | defined( 'ABSPATH' ) || exit; |
| 21 | |
| 22 | do_action( 'woocommerce_before_mini_cart' ); ?> |
| 23 | |
| 24 | <?php if ( ! WC()->cart->is_empty() ) : ?> |
| 25 | |
| 26 | <ul class="woocommerce-mini-cart cart_list product_list_widget <?php echo esc_attr( $args['list_class'] ); ?>"> |
| 27 | <?php |
| 28 | do_action( 'woocommerce_before_mini_cart_contents' ); |
| 29 | |
| 30 | foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { |
| 31 | $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); |
| 32 | $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key ); |
| 33 | |
| 34 | if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_widget_cart_item_visible', true, $cart_item, $cart_item_key ) ) { |
| 35 | $product_name = apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ); |
| 36 | $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key ); |
| 37 | $product_price = apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); |
| 38 | $product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key ); |
| 39 | ?> |
| 40 | <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 ) ); ?>"> |
| 41 | <?php |
| 42 | echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 43 | 'woocommerce_cart_item_remove_link', |
| 44 | sprintf( |
| 45 | '<a href="%s" class="remove remove_from_cart_button" aria-label="%s" data-product_id="%s" data-cart_item_key="%s" data-product_sku="%s">×</a>', |
| 46 | esc_url( wc_get_cart_remove_url( $cart_item_key ) ), |
| 47 | esc_attr__( 'Remove this item', 'woocommerce' ), |
| 48 | esc_attr( $product_id ), |
| 49 | esc_attr( $cart_item_key ), |
| 50 | esc_attr( $_product->get_sku() ) |
| 51 | ), |
| 52 | $cart_item_key |
| 53 | ); |
| 54 | ?> |
| 55 | <?php if ( empty( $product_permalink ) ) : ?> |
| 56 | <?php echo $thumbnail . $product_name; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 57 | <?php else : ?> |
| 58 | <a href="<?php echo esc_url( $product_permalink ); ?>"> |
| 59 | <?php echo $thumbnail . $product_name; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 60 | </a> |
| 61 | <?php endif; ?> |
| 62 | <?php echo wc_get_formatted_cart_item_data( $cart_item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 63 | <?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 ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 64 | </li> |
| 65 | <?php |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | do_action( 'woocommerce_mini_cart_contents' ); |
| 70 | ?> |
| 71 | </ul> |
| 72 | |
| 73 | <p class="woocommerce-mini-cart__total total"> |
| 74 | <?php |
| 75 | /** |
| 76 | * Hook: woocommerce_widget_shopping_cart_total. |
| 77 | * |
| 78 | * @hooked woocommerce_widget_shopping_cart_subtotal - 10 |
| 79 | */ |
| 80 | do_action( 'woocommerce_widget_shopping_cart_total' ); |
| 81 | ?> |
| 82 | </p> |
| 83 | |
| 84 | <?php do_action( 'woocommerce_widget_shopping_cart_before_buttons' ); ?> |
| 85 | |
| 86 | <p class="woocommerce-mini-cart__buttons buttons"><?php do_action( 'woocommerce_widget_shopping_cart_buttons' ); ?></p> |
| 87 | |
| 88 | <?php do_action( 'woocommerce_widget_shopping_cart_after_buttons' ); ?> |
| 89 | |
| 90 | <?php else : ?> |
| 91 | |
| 92 | <p class="woocommerce-mini-cart__empty-message"><?php esc_html_e( 'No products in the cart.', 'woocommerce' ); ?></p> |
| 93 | |
| 94 | <?php endif; ?> |
| 95 | |
| 96 | <?php do_action( 'woocommerce_after_mini_cart' ); ?> |
| 97 |