PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.6.5
ShopBuilder – WooCommerce Builder For Elementor v2.6.5
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
← All changes | app/Modules/Compare/CompareFrontEnd.php +29 -28 2.0.32.6.5 View file →
@@ -32,9 +32,8 @@
32 32 add_shortcode( 'rtsb_compare_button', [ $this, 'button_shortcode' ] );
33 33 add_shortcode( 'rtsb_compare_counter', [ $this, 'counter_shortcode' ] );
34 34
35 35 $this->attach_button();
36 -
37 36 }
38 37
39 38
40 39 public function enqueue() {
@@ -50,10 +49,10 @@
50 49 true
51 50 );
52 51 wp_enqueue_style( 'rtsb-modules' );
53 52 wp_enqueue_script( 'rtsb-compare' );
54 -
55 - $params = apply_filters(
53 + $ajax_button_text = Fns::get_option( 'modules', 'compare', 'button_text', esc_html__( 'Compare', 'shopbuilder' ) );
54 + $params = apply_filters(
56 55 'rtsb/module/compare/js_params',
57 56 [
58 57 'product_id' => get_the_ID(),
59 58 'resturl' => get_rest_url(),
@@ -60,12 +59,14 @@
60 59 'isLoggedIn' => is_user_logged_in(),
61 60 'pageUrl' => CompareFns::instance()->get_page_url(),
62 61 'rest_nonce' => wp_create_nonce( 'wp_rest' ),
63 62 'notice' => [
64 - 'added' => Fns::get_option( 'modules', 'compare', 'notice_added_text', esc_html__( 'Product added!', 'shopbuilder' ) ),
65 - 'removed' => Fns::get_option( 'modules', 'compare', 'notice_removed_text', esc_html__( 'Product removed!', 'shopbuilder' ) ),
66 - 'browse' => Fns::get_option( 'modules', 'compare', 'browse_list_text', esc_html__( 'Browse compare!', 'shopbuilder' ) ),
67 - 'error' => esc_html__( 'Some thing went wrong!!', 'shopbuilder' ),
63 + 'added' => Fns::get_option( 'modules', 'compare', 'notice_added_text', esc_html__( 'Product added!', 'shopbuilder' ) ),
64 + 'removed' => Fns::get_option( 'modules', 'compare', 'notice_removed_text', esc_html__( 'Product removed!', 'shopbuilder' ) ),
65 + 'browse' => Fns::get_option( 'modules', 'compare', 'browse_list_text', esc_html__( 'Browse compare!', 'shopbuilder' ) ),
66 + 'error' => esc_html__( 'Some thing went wrong!!', 'shopbuilder' ),
67 + 'ajax_remove_compare' => esc_html__( 'Remove from list', 'shopbuilder' ),
68 + 'ajax_button_text' => $ajax_button_text,
68 69 ],
69 70 ]
70 71 );
71 72
@@ -98,9 +99,9 @@
98 99 'hook' => 'woocommerce_after_single_product_summary',
99 100 'priority' => 11,
100 101 ],
101 102
102 - 'custom' => [
103 + 'custom' => [
103 104 'hook' => Fns::get_option( 'modules', 'compare', 'product_custom_hook_name', '' ),
104 105 'priority' => Fns::get_option( 'modules', 'compare', 'product_custom_hook_priority', 10 ),
105 106 ],
106 107 ]
@@ -171,10 +172,10 @@
171 172
172 173 /**
173 174 * Add ATW button to Products block item
174 175 *
175 - * @param string $item_html HTML of the single block item.
176 - * @param array $data Data used to render the item.
176 + * @param string $item_html HTML of the single block item.
177 + * @param array $data Data used to render the item.
177 178 * @param WC_Product $product Current product.
178 179 *
179 180 * @return string Filtered HTML.
180 181 */
@@ -237,27 +238,27 @@
237 238 */
238 239 public function print_button( $product_id = 0 ) {
239 240 global $product;
240 241
241 - // product object.
242 - $current_product = $product_id ? wc_get_product( $product_id ) : false;
243 - $current_product = $current_product ?: $product;
242 + if ( ! $product instanceof WC_Product && $product_id ) {
243 + $product = wc_get_product( $product_id );
244 + }
244 245
245 - if ( ! $current_product instanceof WC_Product ) {
246 - return '';
247 - }
246 + // if ( ! $current_product instanceof WC_Product ) {
247 + // return '';
248 + // }
248 249
249 250 // product parent.
250 - $current_product_parent = $current_product->get_parent_id();
251 + $product_parent = $product->get_parent_id();
251 252
252 253 // button class.
253 254 $classes = [];
254 255 // check if product is already in compare list.
255 256 $icon_html = '<i class="rtsb-icon rtsb-icon-arrows-cw"></i>';
256 - $exists = CompareFns::instance()->is_exists_in_list( $current_product->get_id() );
257 + $exists = CompareFns::instance()->is_exists_in_list( $product->get_id() );
257 258 if ( $exists ) {
258 259 $classes[] = 'rtsb-compare-remove';
259 - $button_text = Fns::get_option( 'modules', 'compare', 'button_text', esc_html__( 'Remove from list', 'shopbuilder' ) );
260 + $button_text = esc_html__( 'Remove from list', 'shopbuilder' );
260 261
261 262 $button_text = apply_filters( 'rtsb/modules/compare/remove_from_list_button_text', $button_text );
262 263 } else {
263 264 $classes[] = 'rtsb-compare-add';
@@ -267,18 +268,19 @@
267 268
268 269 // button text.
269 270 $button_text = apply_filters( 'rtsb/module/compare/add_to_list_button_txt', $button_text );
270 271 }
272 +
271 273 // get product type.
272 - $product_type = $current_product->get_type();
274 + $product_type = $product->get_type();
273 275 $params = [
274 276 'exists' => $exists,
275 277 'classes' => $classes,
276 - 'product_id' => $current_product->get_id(),
277 - 'parent_product_id' => $current_product_parent ?: $current_product->get_id(),
278 + 'product_id' => $product->get_id(),
279 + 'parent_product_id' => $product_parent ?: $product->get_id(),
278 280 'product_type' => $product_type,
279 281 'button_text' => $button_text,
280 - 'show_button_text' => false,
282 + 'show_button_text' => ! empty( Fns::get_option( 'modules', 'compare', 'button_text', '' ) ),
281 283 'left_text' => apply_filters( 'rtsb/module/compare/button_left_text', '' ),
282 284 'right_text' => apply_filters( 'rtsb/module/compare/button_right_text', '' ),
283 285 ];
284 286 $atts = apply_filters( 'rtsb/module/compare/button_params', $params );
@@ -285,9 +287,8 @@
285 287
286 288 $atts['icon_html'] = apply_filters( 'rtsb/module/compare/icon_html', $icon_html, $atts );
287 289
288 290 Fns::load_template( 'compare/button', $atts );
289 -
290 291 }
291 292
292 293
293 294 /**
@@ -309,9 +310,9 @@
309 310
310 311 /**
311 312 * List Shortcode callable function
312 313 *
313 - * @param array $atts
314 + * @param array $atts
314 315 * @param string $content
315 316 *
316 317 * @return string [HTML]
317 318 */
@@ -324,9 +325,9 @@
324 325 $empty_text = Fns::get_option( 'modules', 'compare', 'empty_table_text', esc_html__( 'No product found at your list.', 'shopbuilder' ) );
325 326
326 327 /* Product and Field */
327 328 $products = CompareFns::instance()->get_products_data();
328 - $field_ids = [ 'primary' ] + CompareFns::instance()->get_list_field_ids();
329 + $field_ids = array_merge( [ 'primary' ], CompareFns::instance()->get_list_field_ids() );
329 330
330 331 $return_to_shop_text = Fns::get_option( 'modules', 'compare', 'return_to_shop_text', esc_html__( 'Return to shop', 'shopbuilder' ) );
331 332
332 333 $default_atts = [
@@ -346,9 +347,9 @@
346 347
347 348 /**
348 349 * Compare button Shortcode callable function
349 350 *
350 - * @param array $atts
351 + * @param array $atts
351 352 * @param string $content
352 353 *
353 354 * @return string [HTML]
354 355 */
@@ -368,9 +369,9 @@
368 369
369 370 /**
370 371 * Compare counter Shortcode callable function
371 372 *
372 - * @param array $atts
373 + * @param array $atts
373 374 * @param string $content
374 375 *
375 376 * @return string [HTML]
376 377 */