Advertisement
nshelper

Untitled

Jan 9th, 2025
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.92 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. * @package WooCommerce/Templates
  15. * @version 7.9.0
  16. */
  17.  
  18. defined( 'ABSPATH' ) || exit;
  19.  
  20. $update_cart_btn_classes = '';
  21.  
  22. if ( function_exists( 'wc_wp_theme_get_element_class_name' ) ) {
  23. $update_cart_btn_classes .= ' ' . wc_wp_theme_get_element_class_name( 'button' );
  24. }
  25.  
  26. if ( woodmart_get_opt( 'update_cart_quantity_change' ) ) {
  27. $update_cart_btn_classes .= ' wd-hide';
  28. }
  29. ?>
  30.  
  31. <div class="woocommerce cart-content-wrapper">
  32.  
  33. <?php do_action( 'woocommerce_before_cart' ); ?>
  34.  
  35. <form class="woocommerce-cart-form cart-data-form" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">
  36. <div class="cart-table-section">
  37.  
  38. <?php do_action( 'woocommerce_before_cart_table' ); ?>
  39.  
  40. <table class="shop_table shop_table_responsive cart woocommerce-cart-form__contents" cellspacing="0">
  41. <thead>
  42. <tr>
  43. <th class="product-remove"><span class="screen-reader-text"><?php esc_html_e( 'Remove item', 'woocommerce' ); ?></span></th>
  44. <th class="product-thumbnail"><span class="screen-reader-text"><?php esc_html_e( 'Thumbnail image', 'woocommerce' ); ?></span></th>
  45. <th class="product-name"><?php esc_html_e( 'Product', 'woocommerce' ); ?></th>
  46. <?php if ( woodmart_get_opt( 'show_sku_in_cart' ) ) : ?>
  47. <th class="product-sku"><?php esc_html_e( 'SKU', 'woocommerce' ); ?></th>
  48. <?php endif; ?>
  49. <th class="product-price"><?php esc_html_e( 'Price', 'woocommerce' ); ?></th>
  50. <th class="product-quantity"><?php esc_html_e( 'Quantity', 'woocommerce' ); ?></th>
  51. <th class="product-subtotal"><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?></th>
  52. </tr>
  53. </thead>
  54. <tbody>
  55. <?php do_action( 'woocommerce_before_cart_contents' ); ?>
  56.  
  57. <?php
  58. foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
  59. do_action( 'woocommerce/cart_loop/start', $cart_item );
  60. $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
  61. $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
  62.  
  63. if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
  64. $product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key );
  65. $product_name = apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key );
  66. ?>
  67.  
  68. <tr class="woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
  69.  
  70. <td class="product-remove">
  71. <?php
  72. echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  73. 'woocommerce_cart_item_remove_link',
  74. sprintf(
  75. '<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">&times;</a>',
  76. esc_url( wc_get_cart_remove_url( $cart_item_key ) ),
  77. /* translators: %s is the product name */
  78. esc_attr( sprintf( __( 'Remove %s from cart', 'woocommerce' ), wp_strip_all_tags( $product_name ) ) ),
  79. esc_attr( $product_id ),
  80. esc_attr( $_product->get_sku() )
  81. ),
  82. $cart_item_key
  83. );
  84. ?>
  85. </td>
  86.  
  87. <td class="product-thumbnail">
  88. <?php
  89. if ( ! $product_permalink ) {
  90. echo apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
  91. } else {
  92. printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key ) );
  93. }
  94. ?>
  95. </td>
  96.  
  97. <td class="product-name" data-title="<?php esc_attr_e( 'Product', 'woocommerce' ); ?>">
  98. <?php
  99. if ( ! $product_permalink ) {
  100. echo wp_kses_post( $product_name . '&nbsp;' );
  101. } else {
  102. /**
  103. * This filter is documented above.
  104. *
  105. * @since 7.8.0
  106. * @param string $product_url URL the product in the cart.
  107. */
  108. echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $_product->get_name() ), $cart_item, $cart_item_key ) );
  109. }
  110.  
  111. do_action( 'woocommerce_after_cart_item_name', $cart_item, $cart_item_key );
  112.  
  113. // Meta data
  114. echo wc_get_formatted_cart_item_data( $cart_item );
  115.  
  116. // Backorder notification
  117. if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) {
  118. echo wp_kses_post( apply_filters( 'woocommerce_cart_item_backorder_notification', '<p class="backorder_notification">' . esc_html__( 'Available on backorder', 'woocommerce' ) . '</p>', $product_id ) );
  119. }
  120. ?>
  121. </td>
  122.  
  123. <?php if ( woodmart_get_opt( 'show_sku_in_cart' ) ) : ?>
  124. <td class="product-sku" data-title="<?php esc_attr_e( 'SKU', 'woocommerce' ); ?>">
  125. <?php if ( $_product->get_sku() ) : ?>
  126. <?php echo esc_html( $_product->get_sku() ); ?>
  127. <?php else : ?>
  128. <?php esc_html_e( 'N/A', 'woocommerce' ); ?>
  129. <?php endif; ?>
  130. </td>
  131. <?php endif; ?>
  132.  
  133. <td class="product-price" data-title="<?php esc_attr_e( 'Price', 'woocommerce' ); ?>">
  134. <?php
  135.  
  136. $product_price = WC()->cart->get_product_price( $_product );
  137.  
  138. echo apply_filters( 'woocommerce_cart_item_price', $product_price, $cart_item, $cart_item_key );
  139. ?>
  140. </td>
  141.  
  142. <td class="product-quantity" data-title="<?php esc_attr_e( 'Quantity', 'woocommerce' ); ?>">
  143. <?php
  144. if ( $_product->is_sold_individually() ) {
  145. $min_quantity = 1;
  146. $max_quantity = 1;
  147. } else {
  148. $min_quantity = 0;
  149. $max_quantity = $_product->get_max_purchase_quantity();
  150. }
  151.  
  152. $product_quantity = woocommerce_quantity_input(
  153. array(
  154. 'input_name' => "cart[{$cart_item_key}][qty]",
  155. 'input_value' => $cart_item['quantity'],
  156. 'max_value' => $max_quantity,
  157. 'min_value' => $min_quantity,
  158. 'product_name' => $product_name,
  159. ),
  160. $_product,
  161. false
  162. );
  163.  
  164. echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item );
  165. ?>
  166. </td>
  167.  
  168. <td class="product-subtotal" data-title="<?php esc_attr_e( 'Subtotal', 'woocommerce' ); ?>">
  169. <?php
  170. echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key );
  171. ?>
  172. </td>
  173. </tr>
  174.  
  175. <?php
  176. }
  177. do_action( 'woocommerce/cart_loop/end', $cart_item );
  178. }
  179. ?>
  180.  
  181. <?php do_action( 'woocommerce_cart_contents' ); ?>
  182.  
  183. <tr class="wd-cart-action-row">
  184. <td colspan="12" class="actions">
  185. <div class="cart-actions">
  186. <?php if ( wc_coupons_enabled() ) { ?>
  187. <div class="coupon wd-coupon-form">
  188. <label for="coupon_code" class="screen-reader-text">
  189. <?php esc_html_e( 'Coupon:', 'woocommerce' ); ?>
  190. </label>
  191. <input type="text" name="coupon_code" class="input-text" id="coupon_code" value="" placeholder="<?php esc_attr_e( 'Coupon code', 'woocommerce' ); ?>" />
  192. <button type="submit" class="button<?php echo esc_attr( function_exists( 'wc_wp_theme_get_element_class_name' ) && wc_wp_theme_get_element_class_name( 'button' ) ? ' ' . wc_wp_theme_get_element_class_name( 'button' ) : '' ); ?>" name="apply_coupon" value="<?php esc_attr_e( 'Apply coupon', 'woocommerce' ); ?>">
  193. <?php esc_attr_e( 'Apply coupon', 'woocommerce' ); ?>
  194. </button>
  195. <?php do_action( 'woocommerce_cart_coupon' ); ?>
  196. </div>
  197. <?php } ?>
  198.  
  199. <button type="submit" class="button<?php echo esc_attr( $update_cart_btn_classes ); ?>" name="update_cart" value="<?php esc_attr_e( 'Update cart', 'woocommerce' ); ?>">
  200. <?php esc_html_e( 'Update cart', 'woocommerce' ); ?>
  201. </button>
  202.  
  203. <?php do_action( 'woocommerce_cart_actions' ); ?>
  204.  
  205. <?php wp_nonce_field( 'woocommerce-cart', 'woocommerce-cart-nonce' ); ?>
  206. </div>
  207. </td>
  208. </tr>
  209.  
  210. <?php do_action( 'woocommerce_after_cart_contents' ); ?>
  211. </tbody>
  212. </table>
  213.  
  214. <?php do_action( 'woocommerce_after_cart_table' ); ?>
  215. </div>
  216. </form>
  217.  
  218. <?php do_action( 'woocommerce_before_cart_collaterals' ); ?>
  219. <div class="cart-totals-section cart-collaterals">
  220. <?php woocommerce_cart_totals(); ?>
  221. </div>
  222.  
  223. <div class="cart-collaterals">
  224.  
  225. <?php
  226. /**
  227. * Cart collaterals hook.
  228. *
  229. * @hooked woocommerce_cross_sell_display
  230. * @hooked woocommerce_cart_totals - 10
  231. */
  232. do_action( 'woocommerce_cart_collaterals' );
  233. ?>
  234.  
  235. </div>
  236.  
  237. <?php do_action( 'woocommerce_after_cart' ); ?>
  238. </div>
  239.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement