| 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 5.2.0 |
| 18 |
*/ |
| 19 |
|
| 20 |
defined( 'ABSPATH' ) || exit; |
| 21 |
|
| 22 |
do_action( 'woocommerce_before_mini_cart' ); ?> |
| 23 |
|
| 24 |
<?php if ( ! WC()->cart->is_empty() ) : ?> |
| 25 |
<div class="orderable-sb-container" data-orderable-scroll-id="cart"> |
| 26 |
<ul class="orderable-mini-cart <?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 |
$formatted_cart_data = wc_get_formatted_cart_item_data( $cart_item, true ); |
| 40 |
?> |
| 41 |
<li class="orderable-mini-cart-item <?php echo esc_attr( apply_filters( 'woocommerce_mini_cart_item_class', 'mini_cart_item', $cart_item, $cart_item_key ) ); ?>"> |
| 42 |
<?php |
| 43 |
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 44 |
'woocommerce_cart_item_remove_link', |
| 45 |
sprintf( |
| 46 |
'<a href="%s" class="orderable-mini-cart-item__remove remove_from_cart_button" aria-label="%s" data-product_id="%s" data-cart_item_key="%s" data-product_sku="%s">×</a>', |
| 47 |
esc_url( wc_get_cart_remove_url( $cart_item_key ) ), |
| 48 |
esc_attr__( 'Remove this item', 'woocommerce' ), |
| 49 |
esc_attr( $product_id ), |
| 50 |
esc_attr( $cart_item_key ), |
| 51 |
esc_attr( $_product->get_sku() ) |
| 52 |
), |
| 53 |
$cart_item_key |
| 54 |
); |
| 55 |
?> |
| 56 |
<strong><?php echo wp_kses_post( $product_name ); ?></strong> |
| 57 |
|
| 58 |
<?php if ( ! empty( $formatted_cart_data ) ) { ?> |
| 59 |
<div><?php echo wp_kses_post( nl2br( $formatted_cart_data ) ); ?></div> |
| 60 |
<?php } ?> |
| 61 |
|
| 62 |
<div class="orderable-quantity-roller"> |
| 63 |
<span class="orderable-quantity-roller__roller"> |
| 64 |
<button class="orderable-quantity-roller__button orderable-quantity-roller__button--decrease" data-orderable-trigger="decrease-quantity" data-orderable-cart-item-key="<?php echo esc_attr( $cart_item_key ); ?>" data-orderable-product-id="<?php echo esc_attr( $product_id ); ?>" data-orderable-quantity="<?php echo esc_attr( $cart_item['quantity'] ); ?>">-</button> |
| 65 |
<span class="orderable-quantity-roller__quantity"><?php echo esc_html( $cart_item['quantity'] ); ?></span> |
| 66 |
<button class="orderable-quantity-roller__button orderable-quantity-roller__button--increase" data-orderable-trigger="increase-quantity" data-orderable-cart-item-key="<?php echo esc_attr( $cart_item_key ); ?>" data-orderable-product-id="<?php echo esc_attr( $product_id ); ?>" data-orderable-quantity="<?php echo esc_attr( $cart_item['quantity'] ); ?>">+</button> |
| 67 |
</span> |
| 68 |
<span class="orderable-quantity-roller__price"><?php echo wp_kses_post( $product_price ); ?></span> |
| 69 |
</div> |
| 70 |
</li> |
| 71 |
<?php |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
do_action( 'woocommerce_mini_cart_contents' ); |
| 76 |
?> |
| 77 |
</ul> |
| 78 |
</div> |
| 79 |
|
| 80 |
<?php if ( Orderable_Helpers::has_notices() ) { ?> |
| 81 |
<div class="orderable-mini-cart__notices"> |
| 82 |
<?php wc_print_notices(); ?> |
| 83 |
</div> |
| 84 |
<?php } ?> |
| 85 |
|
| 86 |
<?php do_action( 'woocommerce_widget_shopping_cart_before_total' ); ?> |
| 87 |
|
| 88 |
<p class="orderable-mini-cart__total total"> |
| 89 |
<?php |
| 90 |
/** |
| 91 |
* Hook: woocommerce_widget_shopping_cart_total. |
| 92 |
* |
| 93 |
* @hooked woocommerce_widget_shopping_cart_subtotal - 10 |
| 94 |
*/ |
| 95 |
do_action( 'woocommerce_widget_shopping_cart_total' ); |
| 96 |
?> |
| 97 |
</p> |
| 98 |
|
| 99 |
<?php do_action( 'woocommerce_widget_shopping_cart_before_buttons' ); ?> |
| 100 |
|
| 101 |
<p class="orderable-mini-cart__buttons buttons"><?php do_action( 'woocommerce_widget_shopping_cart_buttons' ); ?></p> |
| 102 |
|
| 103 |
<?php do_action( 'woocommerce_widget_shopping_cart_after_buttons' ); ?> |
| 104 |
|
| 105 |
<?php else : ?> |
| 106 |
|
| 107 |
<p class="orderable-mini-cart__empty-message"><?php esc_html_e( 'No products in the cart.', 'woocommerce' ); ?></p> |
| 108 |
|
| 109 |
<?php endif; ?> |
| 110 |
|
| 111 |
<?php do_action( 'woocommerce_after_mini_cart' ); ?> |
| 112 |
|