PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.1.7
ShopBuilder – WooCommerce Builder For Elementor v2.1.7
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.7, at app/Elementor/Widgets/Cart/CartTable.php

158 lines 4.5 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 $controllers = $this->get_settings_for_display();
76 $inner_border = ! empty( $controllers['show_inner_border'] ) ? 'show-inner-border' : '';
77 ?>
78 <!-- Quantity Wrapper Start -->
79 <div class="rtsb-quantity-box-group rtsb-quantity-box-group-<?php echo esc_attr( $controllers['quantity_style'] . ' ' . $inner_border ); ?>">
80 <?php
81 if ( in_array( $controllers['quantity_style'], [ 'style-1', 'style-2' ] ) ) { ?>
82 <button type="button" class="rtsb-quantity-btn rtsb-quantity-minus">
83 <?php echo Fns::icons_manager( $controllers['decrement_icon'] ); ?>
84 </button>
85 <?php
86 }
87 if ( in_array( $controllers['quantity_style'], [ 'style-3', 'style-4' ] ) ) { ?>
88 <div class="rtsb-qty-btns-group">
89 <button type="button" class="rtsb-quantity-btn rtsb-quantity-plus">
90 <?php echo Fns::icons_manager( $controllers['increment_icon'] ); ?>
91 </button>
92 <button type="button" class="rtsb-quantity-btn rtsb-quantity-minus">
93 <?php echo Fns::icons_manager( $controllers['decrement_icon'] ); ?>
94 </button>
95 </div>
96 <?php
97 }
98 }
99
100 public function after_quantity_input_field() {
101 $controllers = $this->get_settings_for_display();
102 if ( in_array( $controllers['quantity_style'], [ 'style-1', 'style-2' ] ) ) { ?>
103 <button type="button" class="rtsb-quantity-btn rtsb-quantity-plus">
104 <?php echo Fns::icons_manager( $controllers['increment_icon'] ); ?>
105 </button>
106 <?php
107 }
108 ?>
109 </div>
110 <!-- Quantity Wrapper End -->
111 <?php
112 }
113
114 /**
115 * @return void
116 */
117 public function apply_the_hooks() {
118 add_action( 'woocommerce_before_quantity_input_field', [ $this, 'before_quantity_input_field' ] );
119 add_action( 'woocommerce_after_quantity_input_field', [ $this, 'after_quantity_input_field' ] );
120 remove_action( 'woocommerce_before_cart', 'woocommerce_output_all_notices', 10 );
121 }
122
123 /**
124 * Render Function
125 *
126 * @return void
127 */
128 protected function render() {
129 $controllers = $this->get_settings_for_display();
130 $this->apply_the_hooks();
131 do_action('rtsb/before/product/cart/table', $controllers, $this );
132 $this->theme_support();
133 $data = [
134 'template' => 'elementor/cart/cart-table',
135 'controllers' => $controllers,
136 'is_builder' => $this->is_builder_mode(),
137 ];
138 if ( $data['is_builder'] ) {
139 wc_load_cart();
140 }
141
142 if ( ! empty( $controllers['cart_empty_message'] ) ) {
143 add_filter( 'wc_empty_cart_message', [ $this, 'cart_empty_message' ] );
144 }
145
146 if ( ! empty( $controllers['return_to_shop_text'] ) ) {
147 add_filter( 'woocommerce_return_to_shop_text', [ $this, 'return_to_shop_text' ] );
148 }
149
150 WC()->cart->calculate_totals();
151
152 Fns::load_template( $data['template'], $data );
153 do_action('rtsb/after/product/cart/table', $controllers, $this );
154 $this->theme_support( 'render_reset' );
155 }
156
157 }
158