PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.1.11
ShopBuilder – WooCommerce Builder For Elementor v2.1.11
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 / app / Elementor / Widgets / Cart / CartTable.php

CartTable.php in ShopBuilder – WooCommerce Builder For Elementor 2.1.11, at app/Elementor/Widgets/Cart/CartTable.php

169 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Main ProductDescription class.
4 *
5 * @package RadiusTheme\SB
6 */
7
8 namespace RadiusTheme\SB\Elementor\Widgets\Cart;
9
10 use RadiusTheme\SB\Helpers\Fns;
11 use RadiusTheme\SB\Abstracts\ElementorWidgetBase;
12 use RadiusTheme\SB\Elementor\Widgets\Controls\CartTableSettings;
13
14 // Do not allow directly accessing this file.
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit( 'This script cannot be accessed directly.' );
17 }
18
19 /**
20 * Product Description class
21 */
22 class CartTable extends ElementorWidgetBase {
23 /**
24 * Construct function
25 *
26 * @param array $data default array.
27 * @param mixed $args default arg.
28 */
29 public function __construct( $data = [], $args = null ) {
30 $this->rtsb_name = esc_html__( 'Cart Table', 'shopbuilder' );
31 $this->rtsb_base = 'rtsb-product-carttable';
32 parent::__construct( $data, $args );
33 }
34 /**
35 * Widget Field
36 *
37 * @return array
38 */
39 public function widget_fields() {
40 return CartTableSettings::widget_fields( $this );
41 }
42 /**
43 * Set Widget Keyword.
44 *
45 * @return array
46 */
47 public function get_keywords() {
48 return [ 'Cart' ] + parent::get_keywords();
49 }
50 /**
51 * Set Widget Keyword.
52 *
53 * @return array
54 */
55 public function cart_empty_message() {
56 $controllers = $this->get_settings_for_display();
57 return $controllers['cart_empty_message'];
58 }
59 /**
60 * Set Widget Keyword.
61 *
62 * @return array
63 */
64 public function return_to_shop_text() {
65 $controllers = $this->get_settings_for_display();
66 return $controllers['return_to_shop_text'];
67 }
68
69 /**
70 * Set Widget Keyword.
71 *
72 * @return array
73 */
74 public function before_quantity_input_field() {
75 global $product;
76 $is_visible_qty = Fns::is_visible_qty_input( $product );
77 $controllers = $this->get_settings_for_display();
78 $inner_border = ! empty( $controllers['show_inner_border'] ) ? 'show-inner-border' : '';
79
80 ?>
81 <!-- Quantity Wrapper Start -->
82 <div class="rtsb-quantity-box-group rtsb-quantity-box-group-<?php echo esc_attr( $controllers['quantity_style'] . ' ' . $inner_border ); ?>">
83 <?php
84 if ( in_array( $controllers['quantity_style'], [ 'style-1', 'style-2' ] ) && $is_visible_qty ) {
85 ?>
86 <button type="button" class="rtsb-quantity-btn rtsb-quantity-minus">
87 <?php Fns::print_html( Fns::icons_manager( $controllers['decrement_icon'] ), true ); ?>
88 </button>
89 <?php
90 }
91 if ( in_array( $controllers['quantity_style'], [ 'style-3', 'style-4' ] ) && $is_visible_qty ) {
92 ?>
93 <div class="rtsb-qty-btns-group">
94 <button type="button" class="rtsb-quantity-btn rtsb-quantity-plus">
95 <?php Fns::print_html( Fns::icons_manager( $controllers['increment_icon'] ), true ); ?>
96 </button>
97 <button type="button" class="rtsb-quantity-btn rtsb-quantity-minus">
98 <?php Fns::print_html( Fns::icons_manager( $controllers['decrement_icon'] ), true ); ?>
99 </button>
100 </div>
101 <?php
102 }
103 }
104
105 public function after_quantity_input_field() {
106
107 global $product;
108 $is_visible_qty = Fns::is_visible_qty_input( $product );
109 $controllers = $this->get_settings_for_display();
110 if ( in_array( $controllers['quantity_style'], [ 'style-1', 'style-2' ] ) && $is_visible_qty ) {
111 ?>
112 <button type="button" class="rtsb-quantity-btn rtsb-quantity-plus">
113 <?php Fns::print_html( Fns::icons_manager( $controllers['increment_icon'] ), true ); ?>
114 </button>
115 <?php
116 }
117 ?>
118 </div>
119 <!-- Quantity Wrapper End -->
120 <?php
121 }
122
123 /**
124 * @return void
125 */
126 public function apply_the_hooks() {
127 add_action( 'woocommerce_before_quantity_input_field', [ $this, 'before_quantity_input_field' ] );
128 add_action( 'woocommerce_after_quantity_input_field', [ $this, 'after_quantity_input_field' ] );
129 remove_action( 'woocommerce_before_cart', 'woocommerce_output_all_notices', 10 );
130 }
131
132 /**
133 * Render Function
134 *
135 * @return void
136 */
137 protected function render() {
138 $controllers = $this->get_settings_for_display();
139 $this->apply_the_hooks();
140 do_action( 'rtsb/before/product/cart/table', $controllers, $this );
141 $this->theme_support();
142 $data = [
143 'template' => 'elementor/cart/cart-table',
144 'controllers' => $controllers,
145 'is_builder' => $this->is_builder_mode(),
146 ];
147 if ( $data['is_builder'] ) {
148 wc_load_cart();
149 }
150
151 if ( ! empty( $controllers['cart_empty_message'] ) ) {
152 add_filter( 'wc_empty_cart_message', [ $this, 'cart_empty_message' ] );
153 }
154
155 if ( ! empty( $controllers['return_to_shop_text'] ) ) {
156 add_filter( 'woocommerce_return_to_shop_text', [ $this, 'return_to_shop_text' ] );
157 }
158
159 // Check cart items are valid.
160 do_action( 'woocommerce_check_cart_items' );
161
162 WC()->cart->calculate_totals();
163
164 Fns::load_template( $data['template'], $data );
165 do_action( 'rtsb/after/product/cart/table', $controllers, $this );
166 $this->theme_support( 'render_reset' );
167 }
168 }
169