PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.0.2
ShopBuilder – WooCommerce Builder For Elementor v2.0.2
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 +26 -27 2.1.32.0.2 View file →
@@ -32,8 +32,9 @@
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 +
36 37 }
37 38
38 39
39 40 public function enqueue() {
@@ -49,10 +50,10 @@
49 50 true
50 51 );
51 52 wp_enqueue_style( 'rtsb-modules' );
52 53 wp_enqueue_script( 'rtsb-compare' );
53 - $ajax_button_text = Fns::get_option( 'modules', 'compare', 'button_text', esc_html__( 'Compare', 'shopbuilder' ) );
54 - $params = apply_filters(
54 +
55 + $params = apply_filters(
55 56 'rtsb/module/compare/js_params',
56 57 [
57 58 'product_id' => get_the_ID(),
58 59 'resturl' => get_rest_url(),
@@ -59,14 +60,12 @@
59 60 'isLoggedIn' => is_user_logged_in(),
60 61 'pageUrl' => CompareFns::instance()->get_page_url(),
61 62 'rest_nonce' => wp_create_nonce( 'wp_rest' ),
62 63 'notice' => [
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,
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' ),
69 68 ],
70 69 ]
71 70 );
72 71
@@ -99,9 +98,9 @@
99 98 'hook' => 'woocommerce_after_single_product_summary',
100 99 'priority' => 11,
101 100 ],
102 101
103 - 'custom' => [
102 + 'custom' => [
104 103 'hook' => Fns::get_option( 'modules', 'compare', 'product_custom_hook_name', '' ),
105 104 'priority' => Fns::get_option( 'modules', 'compare', 'product_custom_hook_priority', 10 ),
106 105 ],
107 106 ]
@@ -172,10 +171,10 @@
172 171
173 172 /**
174 173 * Add ATW button to Products block item
175 174 *
176 - * @param string $item_html HTML of the single block item.
177 - * @param array $data Data used to render the item.
175 + * @param string $item_html HTML of the single block item.
176 + * @param array $data Data used to render the item.
178 177 * @param WC_Product $product Current product.
179 178 *
180 179 * @return string Filtered HTML.
181 180 */
@@ -238,27 +237,27 @@
238 237 */
239 238 public function print_button( $product_id = 0 ) {
240 239 global $product;
241 240
242 - if ( ! $product instanceof WC_Product && $product_id ) {
243 - $product = wc_get_product( $product_id );
241 + // product object.
242 + $current_product = $product_id ? wc_get_product( $product_id ) : false;
243 + $current_product = $current_product ?: $product;
244 +
245 + if ( ! $current_product instanceof WC_Product ) {
246 + return '';
244 247 }
245 248
246 - // if ( ! $current_product instanceof WC_Product ) {
247 - // return '';
248 - // }
249 -
250 249 // product parent.
251 - $product_parent = $product->get_parent_id();
250 + $current_product_parent = $current_product->get_parent_id();
252 251
253 252 // button class.
254 253 $classes = [];
255 254 // check if product is already in compare list.
256 255 $icon_html = '<i class="rtsb-icon rtsb-icon-arrows-cw"></i>';
257 - $exists = CompareFns::instance()->is_exists_in_list( $product->get_id() );
256 + $exists = CompareFns::instance()->is_exists_in_list( $current_product->get_id() );
258 257 if ( $exists ) {
259 258 $classes[] = 'rtsb-compare-remove';
260 - $button_text = esc_html__( 'Remove from list', 'shopbuilder' );
259 + $button_text = Fns::get_option( 'modules', 'compare', 'button_text', esc_html__( 'Remove from list', 'shopbuilder' ) );
261 260
262 261 $button_text = apply_filters( 'rtsb/modules/compare/remove_from_list_button_text', $button_text );
263 262 } else {
264 263 $classes[] = 'rtsb-compare-add';
@@ -268,16 +267,15 @@
268 267
269 268 // button text.
270 269 $button_text = apply_filters( 'rtsb/module/compare/add_to_list_button_txt', $button_text );
271 270 }
272 -
273 271 // get product type.
274 - $product_type = $product->get_type();
272 + $product_type = $current_product->get_type();
275 273 $params = [
276 274 'exists' => $exists,
277 275 'classes' => $classes,
278 - 'product_id' => $product->get_id(),
279 - 'parent_product_id' => $product_parent ?: $product->get_id(),
276 + 'product_id' => $current_product->get_id(),
277 + 'parent_product_id' => $current_product_parent ?: $current_product->get_id(),
280 278 'product_type' => $product_type,
281 279 'button_text' => $button_text,
282 280 'show_button_text' => false,
283 281 'left_text' => apply_filters( 'rtsb/module/compare/button_left_text', '' ),
@@ -287,8 +285,9 @@
287 285
288 286 $atts['icon_html'] = apply_filters( 'rtsb/module/compare/icon_html', $icon_html, $atts );
289 287
290 288 Fns::load_template( 'compare/button', $atts );
289 +
291 290 }
292 291
293 292
294 293 /**
@@ -310,9 +309,9 @@
310 309
311 310 /**
312 311 * List Shortcode callable function
313 312 *
314 - * @param array $atts
313 + * @param array $atts
315 314 * @param string $content
316 315 *
317 316 * @return string [HTML]
318 317 */
@@ -347,9 +346,9 @@
347 346
348 347 /**
349 348 * Compare button Shortcode callable function
350 349 *
351 - * @param array $atts
350 + * @param array $atts
352 351 * @param string $content
353 352 *
354 353 * @return string [HTML]
355 354 */
@@ -369,9 +368,9 @@
369 368
370 369 /**
371 370 * Compare counter Shortcode callable function
372 371 *
373 - * @param array $atts
372 + * @param array $atts
374 373 * @param string $content
375 374 *
376 375 * @return string [HTML]
377 376 */