PageRenderTime 54ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/templates/cart/cart.php

https://github.com/alexcsandru/woocommerce
PHP | 151 lines | 112 code | 30 blank | 9 comment | 16 complexity | 90f586fe571c2e623492d1ef3d9dad63 MD5 | raw file
Possible License(s): GPL-3.0
  1. <?php
  2. /**
  3. * Cart Page
  4. *
  5. * @author WooThemes
  6. * @package WooCommerce/Templates
  7. * @version 1.6.4
  8. */
  9. if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  10. global $woocommerce;
  11. ?>
  12. <?php $woocommerce->show_messages(); ?>
  13. <form action="<?php echo esc_url( $woocommerce->cart->get_cart_url() ); ?>" method="post">
  14. <?php do_action( 'woocommerce_before_cart_table' ); ?>
  15. <table class="shop_table cart" cellspacing="0">
  16. <thead>
  17. <tr>
  18. <th class="product-remove">&nbsp;</th>
  19. <th class="product-thumbnail">&nbsp;</th>
  20. <th class="product-name"><?php _e( 'Product', 'woocommerce' ); ?></th>
  21. <th class="product-price"><?php _e( 'Price', 'woocommerce' ); ?></th>
  22. <th class="product-quantity"><?php _e( 'Quantity', 'woocommerce' ); ?></th>
  23. <th class="product-subtotal"><?php _e( 'Total', 'woocommerce' ); ?></th>
  24. </tr>
  25. </thead>
  26. <tbody>
  27. <?php do_action( 'woocommerce_before_cart_contents' ); ?>
  28. <?php
  29. if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) {
  30. foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
  31. $_product = $values['data'];
  32. if ( $_product->exists() && $values['quantity'] > 0 ) {
  33. ?>
  34. <tr class = "<?php echo esc_attr( apply_filters('woocommerce_cart_table_item_class', 'cart_table_item', $values, $cart_item_key ) ); ?>">
  35. <!-- Remove from cart link -->
  36. <td class="product-remove">
  37. <?php
  38. echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf('<a href="%s" class="remove" title="%s">&times;</a>', esc_url( $woocommerce->cart->get_remove_url( $cart_item_key ) ), __( 'Remove this item', 'woocommerce' ) ), $cart_item_key );
  39. ?>
  40. </td>
  41. <!-- The thumbnail -->
  42. <td class="product-thumbnail">
  43. <?php
  44. $thumbnail = apply_filters( 'woocommerce_in_cart_product_thumbnail', $_product->get_image(), $values, $cart_item_key );
  45. if ( ! $_product->is_visible() || ( ! empty( $_product->variation_id ) && ! $_product->parent_is_visible() ) )
  46. echo $thumbnail;
  47. else
  48. printf('<a href="%s">%s</a>', esc_url( get_permalink( apply_filters('woocommerce_in_cart_product_id', $values['product_id'] ) ) ), $thumbnail );
  49. ?>
  50. </td>
  51. <!-- Product Name -->
  52. <td class="product-name">
  53. <?php
  54. if ( ! $_product->is_visible() || ( ! empty( $_product->variation_id ) && ! $_product->parent_is_visible() ) )
  55. echo apply_filters( 'woocommerce_in_cart_product_title', $_product->get_title(), $values, $cart_item_key );
  56. else
  57. printf('<a href="%s">%s</a>', esc_url( get_permalink( apply_filters('woocommerce_in_cart_product_id', $values['product_id'] ) ) ), apply_filters('woocommerce_in_cart_product_title', $_product->get_title(), $values, $cart_item_key ) );
  58. // Meta data
  59. echo $woocommerce->cart->get_item_data( $values );
  60. // Backorder notification
  61. if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $values['quantity'] ) )
  62. echo '<p class="backorder_notification">' . __( 'Available on backorder', 'woocommerce' ) . '</p>';
  63. ?>
  64. </td>
  65. <!-- Product price -->
  66. <td class="product-price">
  67. <?php
  68. $product_price = get_option('woocommerce_tax_display_cart') == 'excl' ? $_product->get_price_excluding_tax() : $_product->get_price_including_tax();
  69. echo apply_filters('woocommerce_cart_item_price_html', woocommerce_price( $product_price ), $values, $cart_item_key );
  70. ?>
  71. </td>
  72. <!-- Quantity inputs -->
  73. <td class="product-quantity">
  74. <?php
  75. if ( $_product->is_sold_individually() ) {
  76. $product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
  77. } else {
  78. $step = apply_filters( 'woocommerce_quantity_input_step', '1', $_product );
  79. $min = apply_filters( 'woocommerce_quantity_input_min', '', $_product );
  80. $max = apply_filters( 'woocommerce_quantity_input_max', $_product->backorders_allowed() ? '' : $_product->get_stock_quantity(), $_product );
  81. $product_quantity = sprintf( '<div class="quantity"><input type="number" name="cart[%s][qty]" step="%s" min="%s" max="%s" value="%s" size="4" title="' . _x( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) . '" class="input-text qty text" maxlength="12" /></div>', $cart_item_key, $step, $min, $max, esc_attr( $values['quantity'] ) );
  82. }
  83. echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key );
  84. ?>
  85. </td>
  86. <!-- Product subtotal -->
  87. <td class="product-subtotal">
  88. <?php
  89. echo apply_filters( 'woocommerce_cart_item_subtotal', $woocommerce->cart->get_product_subtotal( $_product, $values['quantity'] ), $values, $cart_item_key );
  90. ?>
  91. </td>
  92. </tr>
  93. <?php
  94. }
  95. }
  96. }
  97. do_action( 'woocommerce_cart_contents' );
  98. ?>
  99. <tr>
  100. <td colspan="6" class="actions">
  101. <?php if ( $woocommerce->cart->coupons_enabled() ) { ?>
  102. <div class="coupon">
  103. <label for="coupon_code"><?php _e( 'Coupon', 'woocommerce' ); ?>:</label> <input name="coupon_code" class="input-text" id="coupon_code" value="" /> <input type="submit" class="button" name="apply_coupon" value="<?php _e( 'Apply Coupon', 'woocommerce' ); ?>" />
  104. <?php do_action('woocommerce_cart_coupon'); ?>
  105. </div>
  106. <?php } ?>
  107. <input type="submit" class="button" name="update_cart" value="<?php _e( 'Update Cart', 'woocommerce' ); ?>" /> <input type="submit" class="checkout-button button alt" name="proceed" value="<?php _e( 'Proceed to Checkout &rarr;', 'woocommerce' ); ?>" />
  108. <?php do_action('woocommerce_proceed_to_checkout'); ?>
  109. <?php $woocommerce->nonce_field('cart') ?>
  110. </td>
  111. </tr>
  112. <?php do_action( 'woocommerce_after_cart_contents' ); ?>
  113. </tbody>
  114. </table>
  115. <?php do_action( 'woocommerce_after_cart_table' ); ?>
  116. </form>
  117. <div class="cart-collaterals">
  118. <?php do_action('woocommerce_cart_collaterals'); ?>
  119. <?php woocommerce_cart_totals(); ?>
  120. <?php woocommerce_shipping_calculator(); ?>
  121. </div>