| 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 |
|
| 14 |
?> |
| 15 |
<div class="rtsb-cart-table woocommerce"> |
| 16 |
<?php |
| 17 |
do_action( 'woocommerce_before_cart' ); |
| 18 |
if ( WC()->cart->is_empty() ) { |
| 19 |
wc_get_template( 'cart/cart-empty.php' ); |
| 20 |
} else { |
| 21 |
?> |
| 22 |
<form class="woocommerce-cart-form" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post"> |
| 23 |
<?php do_action( 'woocommerce_before_cart_table' ); ?> |
| 24 |
<table class="shop_table shop_table_responsive cart woocommerce-cart-form__contents" 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 |
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); |
| 45 |
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key ); |
| 46 |
|
| 47 |
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key ) ) { |
| 48 |
$product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key ); |
| 49 |
?> |
| 50 |
<tr class="woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>"> |
| 51 |
<?php |
| 52 |
foreach ( $controllers['cart_table'] as $table ) { |
| 53 |
$product_name = apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key, $table ); |
| 54 |
switch ( $table['cart_table_items'] ) { |
| 55 |
case 'remove': |
| 56 |
echo '<td class="product-remove elementor-repeater-item-' . esc_attr( $table['_id'] ) . '"><div class="table-column-wrapper">'; |
| 57 |
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 58 |
'woocommerce_cart_item_remove_link', |
| 59 |
sprintf( |
| 60 |
'<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">%s</a>', |
| 61 |
esc_url( wc_get_cart_remove_url( $cart_item_key ) ), |
| 62 |
esc_attr__( 'Remove this item', 'shopbuilder' ), |
| 63 |
esc_attr( $product_id ), |
| 64 |
esc_attr( $_product->get_sku() ), |
| 65 |
! empty( Fns::icons_manager( $table['cart_table_remove_icon'] ) ) ? Fns::icons_manager( $table['cart_table_remove_icon'] ) : '' |
| 66 |
), |
| 67 |
$cart_item_key |
| 68 |
); |
| 69 |
|
| 70 |
echo '</div></td>'; |
| 71 |
break; |
| 72 |
case 'products': |
| 73 |
$show_image_on_mobile = $controllers['show_image_on_mobile'] ? ' show-image-on-mobile' : ' hide-image-on-mobile'; |
| 74 |
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 "> '; |
| 75 |
do_action( 'rtsb/cart/table/products/column', $cart_item_key, $_product, $cart_item, $table ); |
| 76 |
echo '</div></td>'; |
| 77 |
break; |
| 78 |
case 'thumbnail': |
| 79 |
echo '<td class="product-thumbnail elementor-repeater-item-' . esc_attr( $table['_id'] ) . '"><div class="table-column-wrapper ">'; |
| 80 |
|
| 81 |
$thumbnail_size = isset( $table['cart_table_thumbnail_size'] ) ? $table['cart_table_thumbnail_size'] : 'thumbnail'; |
| 82 |
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image( $thumbnail_size ), $cart_item, $cart_item_key ); |
| 83 |
|
| 84 |
if ( ! $product_permalink ) { |
| 85 |
Fns::print_html( $thumbnail, true ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 86 |
} else { |
| 87 |
printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 88 |
} |
| 89 |
|
| 90 |
echo '</div></td>'; |
| 91 |
|
| 92 |
break; |
| 93 |
|
| 94 |
case 'name': |
| 95 |
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">'; |
| 96 |
|
| 97 |
if ( ! $product_permalink ) { |
| 98 |
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . ' ', $table ); |
| 99 |
} else { |
| 100 |
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, $table ) ); |
| 101 |
} |
| 102 |
|
| 103 |
do_action( 'woocommerce_after_cart_item_name', $cart_item, $cart_item_key ); |
| 104 |
|
| 105 |
// Meta data. |
| 106 |
echo wc_get_formatted_cart_item_data( $cart_item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 107 |
|
| 108 |
// Backorder notification. |
| 109 |
if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) { |
| 110 |
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_backorder_notification', '<p class="backorder_notification">' . esc_html__( 'Available on backorder', 'shopbuilder' ) . '</p>', $product_id ) ); |
| 111 |
} |
| 112 |
|
| 113 |
echo '</div></td>'; |
| 114 |
|
| 115 |
break; |
| 116 |
|
| 117 |
case 'price': |
| 118 |
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">'; |
| 119 |
echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 120 |
echo '</div></td>'; |
| 121 |
|
| 122 |
break; |
| 123 |
|
| 124 |
case 'quantity': |
| 125 |
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">'; |
| 126 |
|
| 127 |
if ( $_product->is_sold_individually() ) { |
| 128 |
$min_quantity = 1; |
| 129 |
$max_quantity = 1; |
| 130 |
} else { |
| 131 |
$min_quantity = 0; |
| 132 |
$max_quantity = $_product->get_max_purchase_quantity(); |
| 133 |
} |
| 134 |
|
| 135 |
$product_quantity = woocommerce_quantity_input( |
| 136 |
array( |
| 137 |
'input_name' => "cart[{$cart_item_key}][qty]", |
| 138 |
'input_value' => $cart_item['quantity'], |
| 139 |
'max_value' => $max_quantity, |
| 140 |
'min_value' => $min_quantity, |
| 141 |
'product_name' => $product_name, |
| 142 |
), |
| 143 |
$_product, |
| 144 |
false |
| 145 |
); |
| 146 |
|
| 147 |
echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item, $table); // PHPCS: XSS ok. |
| 148 |
|
| 149 |
echo '</div></td>'; |
| 150 |
|
| 151 |
break; |
| 152 |
|
| 153 |
case 'subtotal': |
| 154 |
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">'; |
| 155 |
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 |
| 156 |
echo '</div></td>'; |
| 157 |
break; |
| 158 |
|
| 159 |
case 'custom_field': |
| 160 |
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">'; |
| 161 |
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 |
| 162 |
echo '</div></td>'; |
| 163 |
|
| 164 |
break; |
| 165 |
|
| 166 |
default: |
| 167 |
break; |
| 168 |
} |
| 169 |
} |
| 170 |
?> |
| 171 |
</tr> |
| 172 |
<?php |
| 173 |
} |
| 174 |
} |
| 175 |
?> |
| 176 |
|
| 177 |
<?php do_action( 'woocommerce_cart_contents' ); ?> |
| 178 |
|
| 179 |
</tbody> |
| 180 |
<tfoot> |
| 181 |
<tr> |
| 182 |
<td colspan="6" class="actions"> |
| 183 |
<div class="actions-button-wrapper"> |
| 184 |
|
| 185 |
<?php if ( ! empty( $controllers['show_coupon_field'] ) && wc_coupons_enabled() ) { ?> |
| 186 |
<div class="coupon"> |
| 187 |
<label for="coupon_code"><?php esc_html_e( 'Coupon:', 'shopbuilder' ); ?></label> |
| 188 |
<input type="text" name="coupon_code" class="input-text" id="coupon_code" value="" |
| 189 |
<?php if ( ! empty( $controllers['cart_table_coupon_placeholder_text'] ) ) { ?> |
| 190 |
placeholder="<?php echo esc_attr( $controllers['cart_table_coupon_placeholder_text'] ); ?>" |
| 191 |
<?php } ?> |
| 192 |
/> |
| 193 |
<button type="submit" class="button" name="apply_coupon" |
| 194 |
<?php if ( ! empty( $controllers['cart_table_coupon_button_text'] ) ) { ?> |
| 195 |
value="<?php echo esc_attr( $controllers['cart_table_coupon_button_text'] ); ?>" |
| 196 |
<?php } ?> |
| 197 |
> |
| 198 |
<?php if ( ! empty( $controllers['cart_table_coupon_button_text'] ) ) { ?> |
| 199 |
<?php echo esc_html( $controllers['cart_table_coupon_button_text'] ); ?> |
| 200 |
<?php } ?> |
| 201 |
</button> |
| 202 |
<?php do_action( 'woocommerce_cart_coupon' ); ?> |
| 203 |
</div> |
| 204 |
<?php } ?> |
| 205 |
<?php do_action( 'rtsb/cart/table/before/update/cart' ); ?> |
| 206 |
<button type="submit" class="button" name="update_cart" |
| 207 |
<?php if ( ! empty( $controllers['cart_table_update_button_text'] ) ) { ?> |
| 208 |
value="<?php esc_attr( $controllers['cart_table_update_button_text'] ); ?>" |
| 209 |
<?php } ?> |
| 210 |
> |
| 211 |
<?php if ( ! empty( $controllers['cart_table_update_button_text'] ) ) { ?> |
| 212 |
<?php echo esc_html( $controllers['cart_table_update_button_text'] ); ?> |
| 213 |
<?php } ?> |
| 214 |
</button> |
| 215 |
<?php do_action( 'woocommerce_cart_actions' ); ?> |
| 216 |
<?php wp_nonce_field( 'woocommerce-cart', 'woocommerce-cart-nonce' ); ?> |
| 217 |
</div> |
| 218 |
</td> |
| 219 |
</tr> |
| 220 |
|
| 221 |
<?php do_action( 'woocommerce_after_cart_contents' ); ?> |
| 222 |
</tfoot> |
| 223 |
</table> |
| 224 |
<?php do_action( 'woocommerce_after_cart_table' ); ?> |
| 225 |
</form> |
| 226 |
<?php } ?> |
| 227 |
<?php do_action( 'woocommerce_after_cart' ); ?> |
| 228 |
</div> |
| 229 |
|