cart.php
201 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 woocommerce-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 echo esc_html($settings['shopengine_cart_table_title']) ?></div> |
| 20 | <div class="shopengine-table__head--th product-price"><?php echo esc_html($settings['shopengine_cart_table_price']) ?></div> |
| 21 | <div class="shopengine-table__head--th product-quantity"><?php echo esc_html($settings['shopengine_cart_table_quantity']) ?></div> |
| 22 | <div class="shopengine-table__head--th product-subtotal"><?php echo esc_html($settings['shopengine_cart_table_subtotal']) ?></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 | $product = esc_html__("View Product Full Details","shopengine"); |
| 54 | if(!$product_permalink) { |
| 55 | shopengine_content_render(\ShopEngine\Utils\Helper::render( $thumbnail )); |
| 56 | } else { |
| 57 | shopengine_content_render(sprintf('<a title="' . $product . '" href="%s">%s</a>', esc_url($product_permalink), $thumbnail)); |
| 58 | } ?> |
| 59 | |
| 60 | <!-- remove button --> |
| 61 | <div class="product-remove"> |
| 62 | <?php |
| 63 | $cart = esc_html__("Remove Cart Item","shopengine"); |
| 64 | ob_start(); |
| 65 | \Elementor\Icons_Manager::render_icon( $settings['shopengine_table_remove_button_icon_change'], [ 'aria-hidden' => 'true' ] ); |
| 66 | $remove_icon = ob_get_clean(); |
| 67 | shopengine_content_render( |
| 68 | apply_filters( |
| 69 | 'woocommerce_cart_item_remove_link', |
| 70 | sprintf( |
| 71 | '<a title="' . $cart . '" href="%s" class="remove remove_from_cart_button" aria-label="%s" data-product_id="%s" data-cart_item_key="%s" data-product_sku="%s"> |
| 72 | %s |
| 73 | </a>', |
| 74 | esc_url(wc_get_cart_remove_url($cart_item_key)), |
| 75 | esc_html__('Remove this item', 'shopengine'), |
| 76 | esc_attr($product_id), |
| 77 | esc_attr( $cart_item_key ), |
| 78 | esc_attr($_product->get_sku()), |
| 79 | $remove_icon, |
| 80 | ), |
| 81 | $cart_item_key |
| 82 | ) |
| 83 | ); |
| 84 | ?> |
| 85 | </div> |
| 86 | </div> |
| 87 | |
| 88 | |
| 89 | </div> |
| 90 | |
| 91 | <!-- product name --> |
| 92 | <div class="shopengine-table__body-item--td product-name" data-title="<?php esc_attr_e('Product', 'shopengine'); ?>"> |
| 93 | <?php |
| 94 | if(!$product_permalink) { |
| 95 | echo wp_kses_post(apply_filters('woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key) . ' '); |
| 96 | } else { |
| 97 | 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)); |
| 98 | } |
| 99 | |
| 100 | do_action('woocommerce_after_cart_item_name', $cart_item, $cart_item_key); |
| 101 | |
| 102 | // Meta data. |
| 103 | shopengine_content_render(wc_get_formatted_cart_item_data($cart_item)); |
| 104 | |
| 105 | // Backorder notification. |
| 106 | if($_product->backorders_require_notification() && $_product->is_on_backorder($cart_item['quantity'])) { |
| 107 | echo wp_kses_post(apply_filters('woocommerce_cart_item_backorder_notification', '<p class="backorder_notification">' . esc_html__('Available on backorder', 'shopengine') . '</p>', $product_id)); |
| 108 | } |
| 109 | ?> |
| 110 | |
| 111 | </div> |
| 112 | |
| 113 | <!-- product price --> |
| 114 | <div class="shopengine-table__body-item--td product-price" data-title="<?php esc_attr_e('Price', 'shopengine'); ?>"> |
| 115 | <?php |
| 116 | shopengine_content_render(apply_filters('woocommerce_cart_item_price', WC()->cart->get_product_price($_product), $cart_item, $cart_item_key)); |
| 117 | ?> |
| 118 | </div> |
| 119 | |
| 120 | <!-- product quantity --> |
| 121 | <div class="shopengine-table__body-item--td product-quantity" data-title="<?php esc_attr_e('Quantity', 'shopengine'); ?>"> |
| 122 | <div class="shopengine-cart-quantity"> |
| 123 | <?php |
| 124 | if($_product->is_sold_individually()) { |
| 125 | $product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key ); |
| 126 | } else { |
| 127 | echo "<span class='minus-button'>−</span>"; |
| 128 | $product_quantity = woocommerce_quantity_input( |
| 129 | array( |
| 130 | 'input_name' => "cart[{$cart_item_key}][qty]", |
| 131 | 'input_value' => $cart_item['quantity'], |
| 132 | 'max_value' => $_product->get_max_purchase_quantity(), |
| 133 | 'min_value' => '0', |
| 134 | 'product_name' => $_product->get_name(), |
| 135 | ), |
| 136 | $_product, |
| 137 | false |
| 138 | ); |
| 139 | echo "<span data-max=".intval($_product->get_max_purchase_quantity())." class='plus-button'>+</span>"; |
| 140 | } |
| 141 | |
| 142 | shopengine_content_render(apply_filters('woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item)); |
| 143 | ?> |
| 144 | </div> |
| 145 | |
| 146 | </div> |
| 147 | |
| 148 | <!-- product subtotal --> |
| 149 | <div class="shopengine-table__body-item--td product-subtotal" data-title="<?php esc_attr_e('Subtotal', 'shopengine'); ?>"> |
| 150 | <?php |
| 151 | shopengine_content_render(apply_filters('woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal($_product, $cart_item['quantity']), $cart_item, $cart_item_key)); |
| 152 | ?> |
| 153 | </div> |
| 154 | |
| 155 | </div> <!-- shopengine cart table body item end --> |
| 156 | <?php |
| 157 | } |
| 158 | } |
| 159 | ?> |
| 160 | |
| 161 | <?php do_action('woocommerce_cart_contents'); ?> |
| 162 | <?php do_action('woocommerce_after_cart_contents'); ?> |
| 163 | |
| 164 | </div> <!-- shopengine cart table body end --> |
| 165 | |
| 166 | <!-------------------------------- |
| 167 | shopengine cart table footer start |
| 168 | ------------------------------- --> |
| 169 | <div class="shopengine-table__footer"> |
| 170 | |
| 171 | <div class="button-group-left"> |
| 172 | <button class="return-to-shop shopengine-footer-button"> |
| 173 | <i class="eicon-arrow-left"></i> |
| 174 | <a title="<?php esc_html_e('Return To Shop','shopengine')?>" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>"> |
| 175 | <?php echo esc_html( apply_filters( 'woocommerce_return_to_shop_text', esc_html($settings['shopengine_cart_continue_shopping_btn']) ) ); ?> |
| 176 | </a> |
| 177 | </button> |
| 178 | </div> |
| 179 | |
| 180 | <div class="button-group-right"> |
| 181 | <button type="submit" class="button update-cart-btn shopengine-footer-button" name="update_cart"> |
| 182 | <i class="eicon-redo"></i> |
| 183 | <?php echo esc_html($settings['shopengine_cart_table_update']);?> |
| 184 | </button> |
| 185 | |
| 186 | <button class="shopengine-footer-button clear-btn" type="submit" name="empty_cart"> |
| 187 | <i class="eicon-trash-o"></i> |
| 188 | <?php echo esc_html($settings['shopengine_cart_table_clear_all']);?> |
| 189 | </button> |
| 190 | </div> |
| 191 | <?php do_action('woocommerce_cart_actions'); ?> |
| 192 | <?php wp_nonce_field('woocommerce-cart', 'woocommerce-cart-nonce'); ?> |
| 193 | |
| 194 | </div> <!-- shopengine cart table footer end --> |
| 195 | |
| 196 | </div> <!-- shopengine cart table end --> |
| 197 | <?php do_action('woocommerce_after_cart_table'); ?> |
| 198 | </form> |
| 199 | |
| 200 | <?php do_action('woocommerce_after_cart'); ?> |
| 201 | </div> |