cart.php
257 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 | <?php |
| 10 | $wcmmq_active = false; |
| 11 | if ( ! function_exists( 'is_plugin_active' ) && file_exists( ABSPATH . 'wp-admin/includes/plugin.php' ) ) { |
| 12 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 13 | } |
| 14 | if ( function_exists( 'is_plugin_active' ) ) { |
| 15 | $wcmmq_active = is_plugin_active( 'woo-min-max-quantity-step-control-single/wcmmq.php' ); |
| 16 | } |
| 17 | ?> |
| 18 | <?php if ( $wcmmq_active ) : ?> |
| 19 | <input type="hidden" name="shopengine_cart_widget" value="1" /> |
| 20 | <?php wp_nonce_field( 'shopengine_cart_widget', 'shopengine_cart_widget_nonce' ); ?> |
| 21 | <?php endif; ?> |
| 22 | |
| 23 | <?php do_action('woocommerce_before_cart_table'); ?> |
| 24 | |
| 25 | <!-- shopengine cart table start --> |
| 26 | <div class="shopengine-table"> |
| 27 | |
| 28 | <!-- ------------------------------- |
| 29 | shopengine cart table head start |
| 30 | -------------------------------------> |
| 31 | <div class="shopengine-table__head"> |
| 32 | <div class="shopengine-table__head--th product-remove"></div> |
| 33 | <div class="shopengine-table__head--th product-name"><?php echo esc_html($settings['shopengine_cart_table_title']) ?></div> |
| 34 | <div class="shopengine-table__head--th product-price"><?php echo esc_html($settings['shopengine_cart_table_price']) ?></div> |
| 35 | <div class="shopengine-table__head--th product-quantity"><?php echo esc_html($settings['shopengine_cart_table_quantity']) ?></div> |
| 36 | <div class="shopengine-table__head--th product-subtotal"><?php echo esc_html($settings['shopengine_cart_table_subtotal']) ?></div> |
| 37 | </div> <!-- shopengine cart table head end --> |
| 38 | |
| 39 | <!--------------------------------------- |
| 40 | shopengine cart table body start |
| 41 | ------------------------------------- --> |
| 42 | <div class="shopengine-table__body"> |
| 43 | <?php do_action('woocommerce_before_cart_contents'); ?> |
| 44 | |
| 45 | <?php |
| 46 | foreach(WC()->cart->get_cart() as $cart_item_key => $cart_item) { |
| 47 | $_product = apply_filters('woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key); |
| 48 | $product_id = apply_filters('woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key); |
| 49 | $is_positional = ($settings['shopengine_cart_table_remove_button_position'] === 'start') || ($settings['shopengine_cart_table_remove_button_position'] === 'end'); |
| 50 | |
| 51 | if($_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters('woocommerce_cart_item_visible', true, $cart_item, $cart_item_key)) { |
| 52 | $product_permalink = apply_filters('woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink($cart_item) : '', $cart_item, $cart_item_key); |
| 53 | ?> |
| 54 | <!-- shopengine cart table body item start --> |
| 55 | <div class="shopengine-table__body-item <?php echo esc_attr(apply_filters('woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key)); ?>"> |
| 56 | |
| 57 | <?php if($is_positional) : ?> |
| 58 | <div class="shopengine-table__body-item--td remove-button"> |
| 59 | |
| 60 | |
| 61 | <!-- remove button --> |
| 62 | <div class="product-remove"> |
| 63 | <?php |
| 64 | $cart = esc_html__("Remove Cart Item","shopengine"); |
| 65 | ob_start(); |
| 66 | \Elementor\Icons_Manager::render_icon( $settings['shopengine_table_remove_button_icon_change'], [ 'aria-hidden' => 'true' ] ); |
| 67 | $remove_icon = ob_get_clean(); |
| 68 | shopengine_content_render( |
| 69 | apply_filters( |
| 70 | 'woocommerce_cart_item_remove_link', |
| 71 | sprintf( |
| 72 | '<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"> |
| 73 | %s |
| 74 | </a>', |
| 75 | esc_url(wc_get_cart_remove_url($cart_item_key)), |
| 76 | esc_html__('Remove this item', 'shopengine'), |
| 77 | esc_attr($product_id), |
| 78 | esc_attr( $cart_item_key ), |
| 79 | esc_attr($_product->get_sku()), |
| 80 | $remove_icon, |
| 81 | ), |
| 82 | $cart_item_key |
| 83 | ) |
| 84 | ); |
| 85 | ?> |
| 86 | </div> |
| 87 | </div> |
| 88 | <?php endif; ?> |
| 89 | |
| 90 | <div class="shopengine-table__body-item--td table-first-body-column"> |
| 91 | |
| 92 | |
| 93 | <!-- Product Thumbnail and remove button together --> |
| 94 | <div class="product-thumbnail" data-title="<?php esc_attr_e('Image', 'shopengine'); ?>"> <?php |
| 95 | $thumbnail = apply_filters('woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key); |
| 96 | $product = esc_html__("View Product Full Details","shopengine"); |
| 97 | if(!$product_permalink) { |
| 98 | shopengine_content_render(\ShopEngine\Utils\Helper::render( $thumbnail )); |
| 99 | } else { |
| 100 | shopengine_content_render(sprintf('<a title="' . $product . '" href="%s">%s</a>', esc_url($product_permalink), $thumbnail)); |
| 101 | } ?> |
| 102 | |
| 103 | <!-- remove button --> |
| 104 | <?php if(!$is_positional) : ?> |
| 105 | <div class="product-remove"> |
| 106 | <?php |
| 107 | $cart = esc_html__("Remove Cart Item","shopengine"); |
| 108 | ob_start(); |
| 109 | \Elementor\Icons_Manager::render_icon( $settings['shopengine_table_remove_button_icon_change'], [ 'aria-hidden' => 'true' ] ); |
| 110 | $remove_icon = ob_get_clean(); |
| 111 | shopengine_content_render( |
| 112 | apply_filters( |
| 113 | 'woocommerce_cart_item_remove_link', |
| 114 | sprintf( |
| 115 | '<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"> |
| 116 | %s |
| 117 | </a>', |
| 118 | esc_url(wc_get_cart_remove_url($cart_item_key)), |
| 119 | esc_html__('Remove this item', 'shopengine'), |
| 120 | esc_attr($product_id), |
| 121 | esc_attr( $cart_item_key ), |
| 122 | esc_attr($_product->get_sku()), |
| 123 | $remove_icon, |
| 124 | ), |
| 125 | $cart_item_key |
| 126 | ) |
| 127 | ); |
| 128 | ?> |
| 129 | </div> |
| 130 | <?php endif; ?> |
| 131 | </div> |
| 132 | |
| 133 | |
| 134 | </div> |
| 135 | |
| 136 | <!-- product name --> |
| 137 | <div class="shopengine-table__body-item--td product-name" data-title="<?php esc_attr_e('Product', 'shopengine'); ?>"> |
| 138 | <?php |
| 139 | if(!$product_permalink) { |
| 140 | echo wp_kses_post(apply_filters('woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key) . ' '); |
| 141 | } else { |
| 142 | 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)); |
| 143 | } |
| 144 | |
| 145 | do_action('woocommerce_after_cart_item_name', $cart_item, $cart_item_key); |
| 146 | |
| 147 | // Meta data. |
| 148 | shopengine_content_render(wc_get_formatted_cart_item_data($cart_item)); |
| 149 | |
| 150 | // Backorder notification. |
| 151 | if($_product->backorders_require_notification() && $_product->is_on_backorder($cart_item['quantity'])) { |
| 152 | echo wp_kses_post(apply_filters('woocommerce_cart_item_backorder_notification', '<p class="backorder_notification">' . esc_html__('Available on backorder', 'shopengine') . '</p>', $product_id)); |
| 153 | } |
| 154 | ?> |
| 155 | |
| 156 | </div> |
| 157 | |
| 158 | <!-- product price --> |
| 159 | <div class="shopengine-table__body-item--td product-price" data-title="<?php esc_attr_e('Price', 'shopengine'); ?>"> |
| 160 | <?php |
| 161 | shopengine_content_render(apply_filters('woocommerce_cart_item_price', WC()->cart->get_product_price($_product), $cart_item, $cart_item_key)); |
| 162 | ?> |
| 163 | </div> |
| 164 | |
| 165 | <!-- product quantity --> |
| 166 | <div class="shopengine-table__body-item--td product-quantity" data-title="<?php esc_attr_e('Quantity', 'shopengine'); ?>"> |
| 167 | <div class="shopengine-cart-quantity"> |
| 168 | <?php $remove_quantity_button = ($settings['shopengine_cart_table_quantity_icon_remove'] === 'yes'); ?> |
| 169 | <?php |
| 170 | if($_product->is_sold_individually()) { |
| 171 | $product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key ); |
| 172 | } else { |
| 173 | $min_qty = apply_filters('woocommerce_quantity_input_min', 0, $_product); |
| 174 | $max_qty = $_product->get_max_purchase_quantity(); |
| 175 | ?> |
| 176 | <?php if(! $remove_quantity_button) : ?> |
| 177 | <span data-min="<?php echo esc_attr($min_qty); ?>" class='minus-button'>−</span> |
| 178 | <?php endif; ?> |
| 179 | <?php |
| 180 | $product_quantity = woocommerce_quantity_input( |
| 181 | array( |
| 182 | 'input_name' => "cart[{$cart_item_key}][qty]", |
| 183 | 'input_value' => $cart_item['quantity'], |
| 184 | 'max_value' => $max_qty, |
| 185 | 'min_value' => $min_qty, |
| 186 | 'product_name' => $_product->get_name(), |
| 187 | ), |
| 188 | $_product, |
| 189 | false |
| 190 | ); |
| 191 | ?> |
| 192 | <?php if(! $remove_quantity_button) : ?> |
| 193 | <span data-max="<?php echo esc_attr($max_qty); ?>" class='plus-button'>+</span> |
| 194 | <?php endif; ?> |
| 195 | <?php |
| 196 | } |
| 197 | |
| 198 | shopengine_content_render(apply_filters('woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item)); |
| 199 | ?> |
| 200 | </div> |
| 201 | |
| 202 | </div> |
| 203 | |
| 204 | <!-- product subtotal --> |
| 205 | <div class="shopengine-table__body-item--td product-subtotal" data-title="<?php esc_attr_e('Subtotal', 'shopengine'); ?>"> |
| 206 | <?php |
| 207 | shopengine_content_render(apply_filters('woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal($_product, $cart_item['quantity']), $cart_item, $cart_item_key)); |
| 208 | ?> |
| 209 | </div> |
| 210 | |
| 211 | </div> <!-- shopengine cart table body item end --> |
| 212 | <?php |
| 213 | } |
| 214 | } |
| 215 | ?> |
| 216 | |
| 217 | <?php do_action('woocommerce_cart_contents'); ?> |
| 218 | <?php do_action('woocommerce_after_cart_contents'); ?> |
| 219 | |
| 220 | </div> <!-- shopengine cart table body end --> |
| 221 | |
| 222 | <!-------------------------------- |
| 223 | shopengine cart table footer start |
| 224 | ------------------------------- --> |
| 225 | <div class="shopengine-table__footer"> |
| 226 | |
| 227 | <div class="button-group-left"> |
| 228 | <button class="return-to-shop shopengine-footer-button"> |
| 229 | <i class="eicon-arrow-left"></i> |
| 230 | <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' ) ) ); ?>"> |
| 231 | <?php echo esc_html( apply_filters( 'woocommerce_return_to_shop_text', esc_html($settings['shopengine_cart_continue_shopping_btn']) ) ); ?> |
| 232 | </a> |
| 233 | </button> |
| 234 | </div> |
| 235 | |
| 236 | <div class="button-group-right"> |
| 237 | <button type="submit" class="button update-cart-btn shopengine-footer-button" name="update_cart"> |
| 238 | <i class="eicon-redo"></i> |
| 239 | <?php echo esc_html($settings['shopengine_cart_table_update']);?> |
| 240 | </button> |
| 241 | |
| 242 | <button class="shopengine-footer-button clear-btn" type="submit" name="empty_cart"> |
| 243 | <i class="eicon-trash-o"></i> |
| 244 | <?php echo esc_html($settings['shopengine_cart_table_clear_all']);?> |
| 245 | </button> |
| 246 | </div> |
| 247 | <?php do_action('woocommerce_cart_actions'); ?> |
| 248 | <?php wp_nonce_field('woocommerce-cart', 'woocommerce-cart-nonce'); ?> |
| 249 | |
| 250 | </div> <!-- shopengine cart table footer end --> |
| 251 | |
| 252 | </div> <!-- shopengine cart table end --> |
| 253 | <?php do_action('woocommerce_after_cart_table'); ?> |
| 254 | </form> |
| 255 | |
| 256 | <?php do_action('woocommerce_after_cart'); ?> |
| 257 | </div> |