Advertisement
Projetos

Cart.php

Aug 2nd, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.08 KB | None | 0 0
  1. <?php
  2. /**
  3. * Cart Page
  4. *
  5. * This template can be overridden by copying it to yourtheme/woocommerce/cart/cart.php.
  6. *
  7. * HOWEVER, on occasion WooCommerce will need to update template files and you
  8. * (the theme developer) will need to copy the new files to your theme to
  9. * maintain compatibility. We try to do this as little as possible, but it does
  10. * happen. When this occurs the version of the template file will be bumped and
  11. * the readme will list any important changes.
  12. *
  13. * @see https://docs.woocommerce.com/document/template-structure/
  14. * @author WooThemes
  15. * @package WooCommerce/Templates
  16. * @version 3.0.3
  17. */
  18.  
  19. if ( ! defined( 'ABSPATH' ) ) {
  20. exit;
  21. }
  22.  
  23. wc_print_notices();
  24.  
  25. do_action( 'woocommerce_before_cart' ); ?>
  26.  
  27. <form class="section_offset" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">
  28.  
  29. <section class="section_offset">
  30.  
  31. <div class="table_wrap">
  32.  
  33. <?php do_action( 'woocommerce_before_cart_table' ); ?>
  34.  
  35. <table class="table_type_1 shopping_cart_table shop_table cart" cellspacing="0">
  36.  
  37. <thead>
  38. <tr>
  39. <th class="product_image_col"><?php esc_html_e('Product Image', 'shopme') ?></th>
  40. <th class="product_title_col"><?php esc_html_e('Product Name', 'shopme') ?></th>
  41. <th><?php esc_html_e('SKU', 'shopme'); ?></th>
  42. <th><?php esc_html_e('Price', 'shopme'); ?></th>
  43. <th class="product_qty_col"><?php esc_html_e('Quantity', 'shopme') ?></th>
  44. <th><?php esc_html_e('Total', 'shopme') ?></th>
  45. <th class="product_actions_col"><?php esc_html_e('Action', 'shopme') ?></th>
  46. </tr>
  47. </thead>
  48.  
  49. <tbody>
  50. <?php do_action( 'woocommerce_before_cart_contents' ); ?>
  51.  
  52. <?php
  53. foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
  54. $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
  55. $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
  56.  
  57. if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
  58. $product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key );
  59. ?>
  60. <tr class="woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
  61.  
  62. <td class="product_image_col" data-title="<?php esc_html_e('Product Image', 'shopme') ?>">
  63.  
  64. <?php
  65. $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(array(80, 80)), $cart_item, $cart_item_key );
  66.  
  67. if ( ! $product_permalink ) {
  68. echo $thumbnail;
  69. } else {
  70. printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail );
  71. }
  72. ?>
  73.  
  74. </td>
  75.  
  76. <td data-title="<?php esc_html_e('Product Name', 'shopme') ?>">
  77.  
  78. <?php
  79. if ( ! $product_permalink ) {
  80. echo apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . '&nbsp;';
  81. } else {
  82. echo apply_filters( 'woocommerce_cart_item_name', sprintf( '<a class="product_title" href="%s">%s</a>', esc_url( $product_permalink ), $_product->get_name() ), $cart_item, $cart_item_key );
  83. }
  84.  
  85. // Meta data
  86. echo WC()->cart->get_item_data( $cart_item );
  87.  
  88. // Backorder notification
  89. if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) {
  90. echo '<p class="backorder_notification">' . esc_html__( 'Available on backorder', 'shopme' ) . '</p>';
  91. }
  92. ?>
  93.  
  94. </td>
  95.  
  96. <td data-title="<?php esc_html_e('SKU', 'shopme') ?>">
  97. <?php echo ($sku = $_product->get_sku()) ? $sku : esc_html__('N/A', 'shopme'); ?>
  98. </td>
  99.  
  100. <td class="subtotal" data-title="<?php esc_html_e('Price', 'shopme') ?>">
  101. <?php echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); ?>
  102. </td>
  103.  
  104. <td data-title="<?php esc_html_e('Quantity', 'shopme') ?>">
  105. <?php
  106. if ( $_product->is_sold_individually() ) {
  107. $product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
  108. } else {
  109. $product_quantity = woocommerce_quantity_input( array(
  110. 'input_name' => "cart[{$cart_item_key}][qty]",
  111. 'input_value' => $cart_item['quantity'],
  112. 'max_value' => $_product->backorders_allowed() ? '' : $_product->get_stock_quantity(),
  113. 'min_value' => '0',
  114. ), $_product, false );
  115. }
  116.  
  117. echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item );
  118. ?>
  119. </td>
  120.  
  121. <td class="total" data-title="<?php esc_html_e('Total', 'shopme') ?>">
  122. <?php echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); ?>
  123. </td>
  124.  
  125. <td data-title="Action">
  126. <button title="<?php esc_html_e('Update Cart', 'shopme') ?>" type="submit" class="button_dark_grey icon_btn edit_product" value="update_cart" name="update_cart"><i class="icon-loop"></i></button>
  127. <?php echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf( '<a href="%s" class="button_dark_grey icon_btn remove_product remove" title="%s"><i class="icon-cancel-2"></i></a>', esc_url( WC()->cart->get_remove_url( $cart_item_key ) ), esc_html__( 'Remove this item', 'shopme' ) ), $cart_item_key ); ?>
  128. </td>
  129.  
  130. </tr>
  131. <?php
  132. }
  133. }
  134.  
  135. do_action( 'woocommerce_cart_contents' ); ?>
  136.  
  137. <?php do_action( 'woocommerce_after_cart_contents' ); ?>
  138.  
  139. </tbody>
  140. </table>
  141.  
  142. <?php do_action( 'woocommerce_after_cart_table' ); ?>
  143.  
  144. </div><!--/ .table_wrap-->
  145.  
  146. <footer class="bottom_box on_the_sides">
  147.  
  148. <div class="left_side">
  149. <a target="_blank" href="<?php echo esc_url(get_post_type_archive_link('product')) ?>" class="button_blue middle_btn"><?php esc_html_e('Continue Shopping', 'shopme') ?></a>
  150. </div>
  151.  
  152. <div class="right_side">
  153. <?php echo apply_filters( 'woocommerce_cart_clear_shopping', sprintf( '<a href="%s" class="button_grey middle_btn">%s</a>', esc_url( WC()->cart->get_cart_url() . '?empty-cart' ), esc_html__('Clear Shopping Cart', 'shopme') ) ); ?>
  154. </div>
  155.  
  156. </footer><!--/ .bottom_box -->
  157.  
  158. </section><!--/ .section_offset-->
  159.  
  160. <section class="section_offset">
  161.  
  162. <div class="row">
  163.  
  164. <div class="col-sm-6">
  165.  
  166. <h3 class="row-title"><?php esc_html_e('Discount Codes', 'shopme'); ?></h3>
  167.  
  168. <div class="theme_box">
  169.  
  170. <p class="form_caption"><?php esc_html_e('Enter your coupon code if you have one.', 'shopme') ?></p>
  171.  
  172. <form id="discount_code">
  173.  
  174. <ul>
  175.  
  176. <li class="row">
  177.  
  178. <div class="col-xs-12">
  179.  
  180. <?php if ( wc_coupons_enabled() ) { ?>
  181.  
  182. <input type="text" name="coupon_code" class="input-text" id="coupon_code" value="" placeholder="<?php esc_html_e( 'Coupon code', 'shopme' ); ?>" />
  183.  
  184. <?php do_action( 'woocommerce_cart_coupon' ); ?>
  185. <?php } ?>
  186.  
  187. <?php do_action( 'woocommerce_cart_actions' ); ?>
  188.  
  189. <?php wp_nonce_field( 'woocommerce-cart' ); ?>
  190.  
  191. </div>
  192.  
  193. </li>
  194.  
  195. </ul>
  196.  
  197. </form>
  198.  
  199. </div><!--/ .theme_box -->
  200.  
  201. <footer class="bottom_box">
  202. <input type="submit" class="button button_grey middle_btn" name="apply_coupon" value="<?php esc_html_e( 'Apply Coupon', 'shopme' ); ?>" />
  203. </footer>
  204.  
  205. </div>
  206.  
  207. <div class="col-sm-6">
  208.  
  209. <?php do_action( 'woocommerce_cart_collaterals' ); ?>
  210.  
  211. </div>
  212.  
  213. </div>
  214.  
  215. </section><!--/ .section_offset-->
  216.  
  217. </form>
  218.  
  219. <?php do_action( 'woocommerce_after_cart' ); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement