cart.php
194 lines
| 1 | <?php |
| 2 | |
| 3 | defined('ABSPATH') || exit; |
| 4 | ?> |
| 5 | <div class="shopengine-cart-table"> |
| 6 | <?php do_action('woocommerce_before_cart'); ?> |
| 7 | |
| 8 | <form class="shopengine-cart-form" action="<?php echo esc_url(wc_get_cart_url()); ?>" method="post"> |
| 9 | |
| 10 | <?php do_action('woocommerce_before_cart_table'); ?> |
| 11 | |
| 12 | <!-- shopengine cart table start --> |
| 13 | <div class="shopengine-table"> |
| 14 | |
| 15 | <!-- ------------------------------- |
| 16 | shopengine cart table head start |
| 17 | -------------------------------------> |
| 18 | <div class="shopengine-table__head"> |
| 19 | <div class="shopengine-table__head--th product-name"><?php esc_html_e('Product Name', 'shopengine'); ?></div> |
| 20 | <div class="shopengine-table__head--th product-price"><?php esc_html_e('Price', 'shopengine'); ?></div> |
| 21 | <div class="shopengine-table__head--th product-quantity"><?php esc_html_e('Quantity', 'shopengine'); ?></div> |
| 22 | <div class="shopengine-table__head--th product-subtotal"><?php esc_html_e('Subtotal', 'shopengine'); ?></div> |
| 23 | </div> <!-- shopengine cart table head end --> |
| 24 | |
| 25 | <!--------------------------------------- |
| 26 | shopengine cart table body start |
| 27 | ------------------------------------- --> |
| 28 | <div class="shopengine-table__body"> |
| 29 | <?php do_action('woocommerce_before_cart_contents'); ?> |
| 30 | |
| 31 | <?php |
| 32 | foreach(WC()->cart->get_cart() as $cart_item_key => $cart_item) { |
| 33 | $_product = apply_filters('woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key); |
| 34 | $product_id = apply_filters('woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key); |
| 35 | |
| 36 | if($_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters('woocommerce_cart_item_visible', true, $cart_item, $cart_item_key)) { |
| 37 | $product_permalink = apply_filters('woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink($cart_item) : '', $cart_item, $cart_item_key); |
| 38 | ?> |
| 39 | <!-- shopengine cart table body item start --> |
| 40 | <div class="shopengine-table__body-item" <?php echo esc_attr(apply_filters('woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key)); ?>"> |
| 41 | |
| 42 | <!-- |
| 43 | @class : table-first-body-column |
| 44 | @content : remove button, thumbnail, product name |
| 45 | --> |
| 46 | |
| 47 | <div class="shopengine-table__body-item--td table-first-body-column"> |
| 48 | |
| 49 | |
| 50 | <!-- Product Thumbnail and remove button together --> |
| 51 | <div class="product-thumbnail" data-title="<?php esc_attr_e('Image', 'shopengine'); ?>"> <?php |
| 52 | $thumbnail = apply_filters('woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key); |
| 53 | if(!$product_permalink) { |
| 54 | echo \ShopEngine\Utils\Helper::render( $thumbnail ); // PHPCS: XSS ok. |
| 55 | } else { |
| 56 | printf('<a href="%s">%s</a>', esc_url($product_permalink), $thumbnail); // PHPCS: XSS ok. |
| 57 | } ?> |
| 58 | |
| 59 | <!-- remove button --> |
| 60 | <div class="product-remove"> |
| 61 | <?php |
| 62 | echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 63 | 'woocommerce_cart_item_remove_link', |
| 64 | sprintf( |
| 65 | '<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">×</a>', |
| 66 | esc_url(wc_get_cart_remove_url($cart_item_key)), |
| 67 | esc_html__('Remove this item', 'shopengine'), |
| 68 | esc_attr($product_id), |
| 69 | esc_attr($_product->get_sku()) |
| 70 | ), |
| 71 | $cart_item_key |
| 72 | ); |
| 73 | ?> |
| 74 | </div> |
| 75 | </div> |
| 76 | |
| 77 | |
| 78 | </div> |
| 79 | |
| 80 | <!-- product name --> |
| 81 | <div class="shopengine-table__body-item--td product-name" data-title="<?php esc_attr_e('Product', 'shopengine'); ?>"> |
| 82 | <?php |
| 83 | if(!$product_permalink) { |
| 84 | echo wp_kses_post(apply_filters('woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key) . ' '); |
| 85 | } else { |
| 86 | 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)); |
| 87 | } |
| 88 | |
| 89 | do_action('woocommerce_after_cart_item_name', $cart_item, $cart_item_key); |
| 90 | |
| 91 | // Meta data. |
| 92 | echo wc_get_formatted_cart_item_data($cart_item); // PHPCS: XSS ok. |
| 93 | |
| 94 | // Backorder notification. |
| 95 | if($_product->backorders_require_notification() && $_product->is_on_backorder($cart_item['quantity'])) { |
| 96 | echo wp_kses_post(apply_filters('woocommerce_cart_item_backorder_notification', '<p class="backorder_notification">' . esc_html__('Available on backorder', 'shopengine') . '</p>', $product_id)); |
| 97 | } |
| 98 | ?> |
| 99 | |
| 100 | </div> |
| 101 | |
| 102 | <!-- product price --> |
| 103 | <div class="shopengine-table__body-item--td product-price" data-title="<?php esc_attr_e('Price', 'shopengine'); ?>"> |
| 104 | <?php |
| 105 | echo apply_filters('woocommerce_cart_item_price', WC()->cart->get_product_price($_product), $cart_item, $cart_item_key); // PHPCS: XSS ok. |
| 106 | ?> |
| 107 | </div> |
| 108 | |
| 109 | <!-- product quantity --> |
| 110 | <div class="shopengine-table__body-item--td product-quantity" data-title="<?php esc_attr_e('Quantity', 'shopengine'); ?>"> |
| 111 | <div class="shopengine-cart-quantity"> |
| 112 | <?php |
| 113 | if($_product->is_sold_individually()) { |
| 114 | echo "<span class='minus-button'>−</span>"; |
| 115 | $product_quantity = sprintf('1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key); |
| 116 | echo "<span class='plus-button'>+</span>"; |
| 117 | } else { |
| 118 | echo "<span class='minus-button'>−</span>"; |
| 119 | $product_quantity = woocommerce_quantity_input( |
| 120 | array( |
| 121 | 'input_name' => "cart[{$cart_item_key}][qty]", |
| 122 | 'input_value' => $cart_item['quantity'], |
| 123 | 'max_value' => $_product->get_max_purchase_quantity(), |
| 124 | 'min_value' => '0', |
| 125 | 'product_name' => $_product->get_name(), |
| 126 | ), |
| 127 | $_product, |
| 128 | false |
| 129 | ); |
| 130 | echo "<span class='plus-button'>+</span>"; |
| 131 | } |
| 132 | |
| 133 | echo apply_filters('woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item); // PHPCS: XSS ok. |
| 134 | ?> |
| 135 | </div> |
| 136 | |
| 137 | </div> |
| 138 | |
| 139 | <!-- product subtotal --> |
| 140 | <div class="shopengine-table__body-item--td product-subtotal" data-title="<?php esc_attr_e('Subtotal', 'shopengine'); ?>"> |
| 141 | <?php |
| 142 | echo apply_filters('woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal($_product, $cart_item['quantity']), $cart_item, $cart_item_key); // PHPCS: XSS ok. |
| 143 | ?> |
| 144 | </div> |
| 145 | |
| 146 | </div> <!-- shopengine cart table body item end --> |
| 147 | <?php |
| 148 | } |
| 149 | } |
| 150 | ?> |
| 151 | |
| 152 | <?php do_action('woocommerce_cart_contents'); ?> |
| 153 | <?php do_action('woocommerce_after_cart_contents'); ?> |
| 154 | |
| 155 | </div> <!-- shopengine cart table body end --> |
| 156 | |
| 157 | <!-------------------------------- |
| 158 | shopengine cart table footer start |
| 159 | ------------------------------- --> |
| 160 | <div class="shopengine-table__footer"> |
| 161 | |
| 162 | <div class="button-group-left"> |
| 163 | <button class="return-to-shop shopengine-footer-button"> |
| 164 | <i class="eicon-arrow-left"></i> |
| 165 | <a href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>"> |
| 166 | <?php echo esc_html( apply_filters( 'woocommerce_return_to_shop_text', esc_html__( 'Continue Shopping', 'shopengine' ) ) ); ?> |
| 167 | </a> |
| 168 | </button> |
| 169 | </div> |
| 170 | |
| 171 | <div class="button-group-right"> |
| 172 | <button type="submit" class="button update-cart-btn shopengine-footer-button" name="update_cart" value="<?php esc_attr_e('Update cart', 'shopengine'); ?>"> |
| 173 | <i class="eicon-redo"></i> |
| 174 | <?php esc_html_e('Update cart', 'shopengine'); ?> |
| 175 | </button> |
| 176 | |
| 177 | |
| 178 | <button class="shopengine-footer-button clear-btn" type="submit" name="empty_cart"> |
| 179 | <i class="eicon-trash-o"></i> |
| 180 | <?php esc_html_e('Clear All', 'shopengine'); ?> |
| 181 | </button> |
| 182 | </div> |
| 183 | <?php do_action('woocommerce_cart_actions'); ?> |
| 184 | <?php wp_nonce_field('woocommerce-cart', 'woocommerce-cart-nonce'); ?> |
| 185 | |
| 186 | </div> <!-- shopengine cart table footer end --> |
| 187 | |
| 188 | </div> <!-- shopengine cart table end --> |
| 189 | <?php do_action('woocommerce_after_cart_table'); ?> |
| 190 | </form> |
| 191 | |
| 192 | |
| 193 | <?php do_action('woocommerce_after_cart'); ?> |
| 194 | </div> |