PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.4
ShopBuilder – WooCommerce Builder For Elementor v3.2.4
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
shopbuilder / templates / elementor / cart / cart-table.php

cart-table.php in ShopBuilder – WooCommerce Builder For Elementor 3.2.4, at templates/elementor/cart/cart-table.php

237 lines 11.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Template variables:
4 *
5 * @var $controllers array Widgets/Addons Settings
6 * @var $is_builder boolean Is Cart Edit page
7 */
8
9 use RadiusTheme\SB\Helpers\Fns;
10
11 defined( 'ABSPATH' ) || exit;
12
13 $horizontal_scroll = ! empty( $controllers['table_horizontal_scroll_on_mobile'] );
14 $wrapper_classes = $horizontal_scroll ? ' rtsb-table-horizontal-scroll-on-mobile' : '';
15 $wrapper_classes .= ! empty( $controllers['ajax_on_qty_change'] ) && rtsb()->has_pro() ? ' has-ajax-update' : ' no-ajax-update';
16 ?>
17 <div class="rtsb-cart-table woocommerce <?php echo esc_attr( $wrapper_classes ); ?>">
18 <?php
19 if ( WC()->cart->is_empty() ) {
20 wc_get_template( 'cart/cart-empty.php' );
21 } else {
22 ?>
23 <form class="woocommerce-cart-form" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">
24 <table class="shop_table cart woocommerce-cart-form__contents <?php echo esc_attr( $horizontal_scroll ? '' : 'shop_table_responsive' ); ?>" cellspacing="0">
25 <thead>
26 <tr>
27 <?php
28 foreach ( $controllers['cart_table'] as $heading ) {
29 printf(
30 '<th class="product-%s elementor-repeater-item-%s"> <div class="table-column-wrapper"> %s </div> </th>',
31 esc_attr( $heading['cart_table_items'] ),
32 esc_attr( $heading['_id'] ),
33 esc_html( $heading['cart_table_heading_title'] )
34 );
35 }
36 ?>
37 </tr>
38 </thead>
39 <tbody>
40 <?php do_action( 'woocommerce_before_cart_contents' ); ?>
41
42 <?php
43 foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
44
45 $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
46 $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
47
48 $GLOBALS['product'] = $_product;
49
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 $show_image_on_mobile = ( $horizontal_scroll || $controllers['show_image_on_mobile'] ) ? ' show-image-on-mobile' : ' hide-image-on-mobile';
55 ?>
56 <tr class="woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
57 <?php
58 foreach ( $controllers['cart_table'] as $table ) {
59 $cart_item['custom_table_data'] = $table;
60 $product_name = apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key );
61 switch ( $table['cart_table_items'] ) {
62 case 'remove':
63 echo '<td class="product-remove elementor-repeater-item-' . esc_attr( $table['_id'] ) . '"><div class="table-column-wrapper">';
64 echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
65 'woocommerce_cart_item_remove_link',
66 sprintf(
67 '<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">%s</a>',
68 esc_url( wc_get_cart_remove_url( $cart_item_key ) ),
69 esc_attr__( 'Remove this item', 'shopbuilder' ),
70 esc_attr( $product_id ),
71 esc_attr( $_product->get_sku() ),
72 ! empty( Fns::icons_manager( $table['cart_table_remove_icon'] ) ) ? Fns::icons_manager( $table['cart_table_remove_icon'] ) : ''
73 ),
74 $cart_item_key
75 );
76
77 echo '</div></td>';
78 break;
79 case 'products':
80 echo '<td class="product-data elementor-repeater-item-' . esc_attr( $table['_id'] ) . esc_attr( $show_image_on_mobile ) . '" data-title="' . esc_attr( $table['cart_table_heading_title'] ) . '"> <div class="table-column-wrapper rtsb-product-column"> ';
81 do_action( 'rtsb/cart/table/products/column', $cart_item_key, $_product, $cart_item, $table, $controllers );
82 echo '</div></td>';
83 break;
84 case 'thumbnail':
85 echo '<td class="product-thumbnail elementor-repeater-item-' . esc_attr( $table['_id'] ) . esc_attr( $show_image_on_mobile ) . '"><div class="table-column-wrapper">';
86
87 $thumbnail_size = isset( $table['cart_table_thumbnail_size'] ) ? $table['cart_table_thumbnail_size'] : 'thumbnail';
88 $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image( $thumbnail_size ), $cart_item, $cart_item_key );
89
90 if ( ! $product_permalink ) {
91 Fns::print_html( $thumbnail, true ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
92 } else {
93 printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
94 }
95
96 echo '</div></td>';
97
98 break;
99
100 case 'name':
101 echo '<td class="product-name elementor-repeater-item-' . esc_attr( $table['_id'] ) . '" data-title="' . esc_attr( $table['cart_table_heading_title'] ) . '"><div class="table-column-wrapper rtsb-product-content">';
102
103 if ( ! $product_permalink ) {
104 echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . '&nbsp;' );
105 } else {
106 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 ) );
107 }
108
109 do_action( 'woocommerce_after_cart_item_name', $cart_item, $cart_item_key );
110
111 if ( ! empty( $table['show_variation_data'] ) ) {
112 Fns::print_html( wc_get_formatted_cart_item_data( $cart_item ), true ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
113 }
114
115 // Backorder notification.
116 if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) {
117 echo wp_kses_post( apply_filters( 'woocommerce_cart_item_backorder_notification', '<p class="backorder_notification">' . esc_html__( 'Available on backorder', 'shopbuilder' ) . '</p>', $product_id ) );
118 }
119
120 echo '</div></td>';
121
122 break;
123
124 case 'price':
125 echo '<td class="product-price elementor-repeater-item-' . esc_attr( $table['_id'] ) . '" data-title="' . esc_attr( $table['cart_table_heading_title'] ) . '"><div class="table-column-wrapper">';
126 echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
127 echo '</div></td>';
128
129 break;
130
131 case 'quantity':
132 echo '<td class="product-quantity elementor-repeater-item-' . esc_attr( $table['_id'] ) . '" data-title="' . esc_attr( $table['cart_table_heading_title'] ) . '"><div class="table-column-wrapper">';
133
134 if ( $_product->is_sold_individually() ) {
135 $min_quantity = 1;
136 $max_quantity = 1;
137 } else {
138 $min_quantity = 0;
139 $max_quantity = $_product->get_max_purchase_quantity();
140 }
141
142 $product_quantity = woocommerce_quantity_input(
143 [
144 'input_name' => "cart[{$cart_item_key}][qty]",
145 'input_value' => $cart_item['quantity'],
146 'max_value' => $max_quantity,
147 'min_value' => $min_quantity,
148 'product_name' => $product_name,
149 ],
150 $_product,
151 false
152 );
153
154 echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item, $table ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
155
156 echo '</div></td>';
157
158 break;
159
160 case 'subtotal':
161 echo '<td class="product-subtotal elementor-repeater-item-' . esc_attr( $table['_id'] ) . '" data-title="' . esc_html( $table['cart_table_heading_title'] ) . '"><div class="table-column-wrapper">';
162 echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key, $table ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
163 echo '</div></td>';
164 break;
165
166 case 'custom_field':
167 echo '<td class="product-subtotal elementor-repeater-item-' . esc_attr( $table['_id'] ) . '" data-title="' . esc_html( $table['cart_table_heading_title'] ) . '"><div class="table-column-wrapper">';
168 echo Fns::get_post_custom_field_value( $product_id, $table['cart_table_custom_field'], $table['cart_table_custom_field_fallback'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
169 echo '</div></td>';
170
171 break;
172
173 default:
174 break;
175 }
176 }
177 ?>
178 </tr>
179 <?php
180 }
181
182 unset( $GLOBALS['product'] );
183
184 }
185 ?>
186
187 <?php do_action( 'woocommerce_cart_contents' ); ?>
188
189 </tbody>
190 <tfoot>
191 <tr>
192 <td colspan="6" class="actions">
193 <div class="actions-button-wrapper">
194
195 <?php if ( ! empty( $controllers['show_coupon_field'] ) && wc_coupons_enabled() ) { ?>
196 <div class="coupon">
197 <label for="coupon_code"><?php esc_html_e( 'Coupon:', 'shopbuilder' ); ?></label>
198 <input type="text" name="coupon_code" class="input-text" id="coupon_code" value=""
199 <?php if ( ! empty( $controllers['cart_table_coupon_placeholder_text'] ) ) { ?>
200 placeholder="<?php echo esc_attr( $controllers['cart_table_coupon_placeholder_text'] ); ?>"
201 <?php } ?>
202 />
203 <button type="submit" class="button" name="apply_coupon"
204 <?php if ( ! empty( $controllers['cart_table_coupon_button_text'] ) ) { ?>
205 value="<?php echo esc_attr( $controllers['cart_table_coupon_button_text'] ); ?>"
206 <?php } ?>
207 >
208 <?php if ( ! empty( $controllers['cart_table_coupon_button_text'] ) ) { ?>
209 <?php echo esc_html( $controllers['cart_table_coupon_button_text'] ); ?>
210 <?php } ?>
211 </button>
212 <?php do_action( 'woocommerce_cart_coupon' ); ?>
213 </div>
214 <?php } ?>
215 <?php do_action( 'rtsb/cart/table/before/update/cart' ); ?>
216 <button type="submit" class="button" name="update_cart"
217 <?php if ( ! empty( $controllers['cart_table_update_button_text'] ) ) { ?>
218 value="<?php esc_attr( $controllers['cart_table_update_button_text'] ); ?>"
219 <?php } ?>
220 >
221 <?php if ( ! empty( $controllers['cart_table_update_button_text'] ) ) { ?>
222 <?php echo esc_html( $controllers['cart_table_update_button_text'] ); ?>
223 <?php } ?>
224 </button>
225 <?php do_action( 'woocommerce_cart_actions' ); ?>
226 <?php wp_nonce_field( 'woocommerce-cart', 'woocommerce-cart-nonce' ); ?>
227 </div>
228 </td>
229 </tr>
230
231 <?php do_action( 'woocommerce_after_cart_contents' ); ?>
232 </tfoot>
233 </table>
234 </form>
235 <?php } ?>
236 </div>
237