PageRenderTime 41ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/templates/cart/mini-cart.php

https://github.com/CammoKing/woocommerce
PHP | 69 lines | 34 code | 24 blank | 11 comment | 10 complexity | d75ba09ede2a466d9019320928b2cecc MD5 | raw file
Possible License(s): GPL-3.0
  1. <?php
  2. /**
  3. * Mini-cart
  4. *
  5. * Contains the markup for the mini-cart, used by the cart widget
  6. *
  7. * @author WooThemes
  8. * @package WooCommerce/Templates
  9. * @version 1.6.4
  10. */
  11. if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  12. global $woocommerce;
  13. ?>
  14. <ul class="cart_list product_list_widget <?php echo $args['list_class']; ?>">
  15. <?php if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) : ?>
  16. <?php foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) :
  17. $_product = $cart_item['data'];
  18. // Only display if allowed
  19. if ( ! apply_filters('woocommerce_widget_cart_item_visible', true, $cart_item, $cart_item_key ) || ! $_product->exists() || $cart_item['quantity'] == 0 )
  20. continue;
  21. // Get price
  22. $product_price = get_option( 'woocommerce_display_cart_prices_excluding_tax' ) == 'yes' || $woocommerce->customer->is_vat_exempt() ? $_product->get_price_excluding_tax() : $_product->get_price();
  23. $product_price = apply_filters( 'woocommerce_cart_item_price_html', woocommerce_price( $product_price ), $cart_item, $cart_item_key );
  24. ?>
  25. <li>
  26. <a href="<?php echo get_permalink( $cart_item['product_id'] ); ?>">
  27. <?php echo $_product->get_image(); ?>
  28. <?php echo apply_filters('woocommerce_widget_cart_product_title', $_product->get_title(), $_product ); ?>
  29. </a>
  30. <?php echo $woocommerce->cart->get_item_data( $cart_item ); ?>
  31. <span class="quantity"><?php printf( '%s &times; %s', $cart_item['quantity'], $product_price ); ?></span>
  32. </li>
  33. <?php endforeach; ?>
  34. <?php else : ?>
  35. <li class="empty"><?php _e( 'No products in the cart.', 'woocommerce' ); ?></li>
  36. <?php endif; ?>
  37. </ul><!-- end product list -->
  38. <?php if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) : ?>
  39. <p class="total"><strong><?php _e( 'Subtotal', 'woocommerce' ); ?>:</strong> <?php echo $woocommerce->cart->get_cart_subtotal(); ?></p>
  40. <?php do_action( 'woocommerce_widget_shopping_cart_before_buttons' ); ?>
  41. <p class="buttons">
  42. <a href="<?php echo $woocommerce->cart->get_cart_url(); ?>" class="button"><?php _e( 'View Cart &rarr;', 'woocommerce' ); ?></a>
  43. <a href="<?php echo $woocommerce->cart->get_checkout_url(); ?>" class="button checkout"><?php _e( 'Checkout &rarr;', 'woocommerce' ); ?></a>
  44. </p>
  45. <?php endif; ?>