| @@ -85,9 +85,10 @@ | ||
| 85 | 85 | public function container( $content, $settings, $class = '', $template = '', $fullwidth = false, $ajax = true ) { |
| 86 | 86 | $rand = wp_rand(); |
| 87 | 87 | $layout_id = 'rtsb-container-' . $rand; |
| 88 | 88 | $metas = RenderHelpers::meta_dataset( $settings, $template ); |
| 89 | - $layout = $metas['layout']; | |
| 89 | + $raw_layout = esc_html( $metas['layout'] ); | |
| 90 | + $layout = RenderHelpers::filter_layout( $raw_layout, $template ); | |
| 90 | 91 | $style_attr = '--rtsb-default-columns: ' . esc_attr( RenderHelpers::default_columns( $layout ) ); |
| 91 | 92 | $view_mode = $settings['view_mode'] ?? 'grid'; |
| 92 | 93 | $view_mode = isset( $_GET['displayview'] ) ? sanitize_text_field( wp_unslash( $_GET['displayview'] ) ) : $view_mode; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 93 | 94 | $tooltip_attr = 'list' == $view_mode && ! empty( $metas['tooltip_position_list'] ) ? esc_attr( $metas['tooltip_position_list'] ) : $metas['tooltip_position']; |
| @@ -108,9 +109,9 @@ | ||
| 108 | 109 | // Attributes for the container. |
| 109 | 110 | $container_attributes = [ |
| 110 | 111 | 'id' => $layout_id, |
| 111 | 112 | 'class' => $container_classes, |
| 112 | - 'style' => $style_attr, | |
| 113 | + 'style' => apply_filters( 'rtsb/product/container/attr', $style_attr, $settings ), | |
| 113 | 114 | 'data-layout' => $layout, |
| 114 | 115 | 'data-tooltip-position' => $tooltip_attr, |
| 115 | 116 | ]; |
| 116 | 117 | |
| @@ -163,13 +164,15 @@ | ||
| 163 | 164 | * |
| 164 | 165 | * @return string |
| 165 | 166 | */ |
| 166 | 167 | public function row( $content, $settings, $hook_html = '', $raw_settings = [] ) { |
| 167 | - $layout = $settings['layout']; | |
| 168 | + $raw_layout = esc_html( $settings['layout'] ); | |
| 169 | + $layout = RenderHelpers::filter_layout( $raw_layout ); | |
| 170 | + | |
| 168 | 171 | $rand = wp_rand(); |
| 169 | - $is_carousel = preg_match( '/slider/', $layout ); | |
| 172 | + $is_carousel = preg_match( '/slider/', $raw_layout ); | |
| 170 | 173 | |
| 171 | - if ( preg_match( '/category/', $layout ) && ( ! empty( $settings['active_cat_slider'] ) ) ) { | |
| 174 | + if ( preg_match( '/category/', $raw_layout ) && ( ! empty( $settings['active_cat_slider'] ) ) ) { | |
| 172 | 175 | $is_carousel = true; |
| 173 | 176 | } |
| 174 | 177 | |
| 175 | 178 | // Row classes. |
| @@ -240,8 +243,9 @@ | ||
| 240 | 243 | |
| 241 | 244 | foreach ( $products as $product ) { |
| 242 | 245 | $i++; |
| 243 | 246 | $GLOBALS['product'] = $product; |
| 247 | + $layout = RenderHelpers::filter_layout( esc_html( $settings['layout'] ), $template ); | |
| 244 | 248 | |
| 245 | 249 | /** |
| 246 | 250 | * Before product template render hook. |
| 247 | 251 | */ |
| @@ -250,9 +254,9 @@ | ||
| 250 | 254 | // Loop arg. |
| 251 | 255 | $arg = $this->arg_dataset( $settings, $product, $settings['lazy_load'], $i ); |
| 252 | 256 | |
| 253 | 257 | // Get template. |
| 254 | - $html .= Fns::load_template( $template . $settings['layout'], $arg, true ); | |
| 258 | + $html .= Fns::load_template( $template . $layout, $arg, true ); | |
| 255 | 259 | |
| 256 | 260 | /** |
| 257 | 261 | * After product template render hook. |
| 258 | 262 | */ |
| @@ -368,10 +372,16 @@ | ||
| 368 | 372 | do_action( 'rtsb/elements/render/before_query', $settings, $args ); |
| 369 | 373 | |
| 370 | 374 | // Query. |
| 371 | 375 | $product_query = new WC_Product_Query( $args ); |
| 372 | - $products = $pagination ? $product_query->get_products()->products : $product_query->get_products(); | |
| 373 | 376 | |
| 377 | + /** | |
| 378 | + * Product query hook. | |
| 379 | + */ | |
| 380 | + do_action( 'rtsb/elements/render/product_query', $product_query, $this ); | |
| 381 | + | |
| 382 | + $products = $pagination ? $product_query->get_products()->products : $product_query->get_products(); | |
| 383 | + | |
| 374 | 384 | if ( ! empty( $products ) ) { |
| 375 | 385 | // Start rendering. |
| 376 | 386 | $hook_html .= $this->render_start( $metas, $settings, $temp_args ); |
| 377 | 387 | |
| @@ -477,9 +487,9 @@ | ||
| 477 | 487 | // Pagination. |
| 478 | 488 | $this->html .= '<div class="rtsb-archive-pagination-wrap">'; |
| 479 | 489 | |
| 480 | 490 | if ( $pagination ) { |
| 481 | - if ( Fns::product_filters_has_ajax( 'shop' ) || Fns::product_filters_has_ajax( 'archive' ) ) { | |
| 491 | + if ( Fns::product_filters_has_ajax( apply_filters( 'rtsb/builder/set/current/page/type', '' ) ) ) { | |
| 482 | 492 | if ( $wp_query->max_num_pages > 1 ) { |
| 483 | 493 | $this->add_attribute( |
| 484 | 494 | 'rtsb_load_more_btn_attr_' . $rand, |
| 485 | 495 | [ |
| @@ -489,9 +499,9 @@ | ||
| 489 | 499 | ); |
| 490 | 500 | |
| 491 | 501 | $this->html .= |
| 492 | 502 | "<div class='rtsb-load-more rtsb-pos-r'> |
| 493 | - <button '{$this->get_attribute_string( 'rtsb_load_more_btn_attr_' . $rand )}'> | |
| 503 | + <button {$this->get_attribute_string( 'rtsb_load_more_btn_attr_' . $rand )}> | |
| 494 | 504 | <span>" . esc_html__( 'Load More', 'shopbuilder' ) . "</span> |
| 495 | 505 | </button> |
| 496 | 506 | <div class='rtsb-loadmore-loading rtsb-ball-clip-rotate'><div></div></div> |
| 497 | 507 | </div>"; |
| @@ -864,8 +874,9 @@ | ||
| 864 | 874 | $arg['anchor_class'] = null; |
| 865 | 875 | $arg['hover_img_html'] = null; |
| 866 | 876 | $arg['s_link'] = []; |
| 867 | 877 | $arg['add_to_cart'] = ''; |
| 878 | + $arg['p_counter'] = absint( $i ); | |
| 868 | 879 | $arg['p_id'] = $post_id; |
| 869 | 880 | $arg['product'] = $product; |
| 870 | 881 | $arg['p_link'] = $product->get_permalink(); |
| 871 | 882 | $arg['p_sale'] = ''; |
| @@ -924,14 +935,16 @@ | ||
| 924 | 935 | $arg['p_sale'] = Fns::is_module_active( 'product_badges' ) && $badge_module ? 'rtsb_yes' : Fns::get_promo_badge( |
| 925 | 936 | $product, |
| 926 | 937 | $meta['sale_badge_type'], |
| 927 | 938 | $meta['sale_badge_text'], |
| 928 | - $meta['out_of_stock_badge_text'] | |
| 939 | + apply_filters( 'rtsb/elementor/render/out_of_stock_badge_text', $meta['out_of_stock_badge_text'] ) | |
| 929 | 940 | ); |
| 930 | 941 | } |
| 931 | 942 | |
| 932 | 943 | $arg['badge_class'] = RenderHelpers::badge_class( $meta['badge_preset'] ); |
| 933 | 944 | |
| 945 | + $meta['add_to_cart_text'] = apply_filters( 'rtsb/elementor/render/add_to_cart_text', $meta['add_to_cart_text'], $product ); | |
| 946 | + | |
| 934 | 947 | if ( ! $meta['show_cart_text'] ) { |
| 935 | 948 | $meta['add_to_cart_text'] = ''; |
| 936 | 949 | $meta['add_to_cart_success_text'] = ''; |
| 937 | 950 | } |
| @@ -957,8 +970,9 @@ | ||
| 957 | 970 | 'text' => $meta['add_to_cart_text'], |
| 958 | 971 | 'success' => $meta['add_to_cart_success_text'], |
| 959 | 972 | 'icon_html' => $cart_icon, |
| 960 | 973 | 'alignment' => $meta['add_to_cart_alignment'], |
| 974 | + 'product' => $product, | |
| 961 | 975 | ] |
| 962 | 976 | ); |
| 963 | 977 | } |
| 964 | 978 | } |
| @@ -1043,9 +1057,10 @@ | ||
| 1043 | 1057 | 'type' => $type, |
| 1044 | 1058 | 'text' => $text, |
| 1045 | 1059 | 'success' => $success, |
| 1046 | 1060 | 'icon_html' => $icon_html, |
| 1047 | - 'alignment' => $alignment | |
| 1061 | + 'alignment' => $alignment, | |
| 1062 | + 'product' => $product | |
| 1048 | 1063 | ) = $args; |
| 1049 | 1064 | |
| 1050 | 1065 | $content = null; |
| 1051 | 1066 | $rand = wp_rand(); |
| @@ -1078,8 +1093,10 @@ | ||
| 1078 | 1093 | |
| 1079 | 1094 | $content .= '<div class="rtsb-wc-add-to-cart-wrap">'; |
| 1080 | 1095 | |
| 1081 | 1096 | if ( 'variable' === $type || 'grouped' === $type ) { |
| 1097 | + $cart_attr = apply_filters( 'rtsb/elementor/render/cart_attributes', $cart_attr, $product ); | |
| 1098 | + | |
| 1082 | 1099 | $this->add_attribute( 'rtsb_add_to_cart_button_' . $id . $rand, $cart_attr ); |
| 1083 | 1100 | |
| 1084 | 1101 | $text_btn = 'grouped' === $type ? __( 'View Products', 'shopbuilder' ) : __( 'Select Options', 'shopbuilder' ); |
| 1085 | 1102 | |
| @@ -1102,8 +1119,9 @@ | ||
| 1102 | 1119 | } else { |
| 1103 | 1120 | $cart_attr['href'] = $cart_attr['href'] . '?add-to-cart=' . absint( $id ); |
| 1104 | 1121 | $cart_attr['class'] .= ' rtsb-add-to-cart-btn'; |
| 1105 | 1122 | $cart_attr['data-type'] = $type; |
| 1123 | + $cart_attr = apply_filters( 'rtsb/elementor/render/cart_attributes', $cart_attr, $product ); | |
| 1106 | 1124 | |
| 1107 | 1125 | $this->add_attribute( 'rtsb_add_to_cart_button_' . $id . $rand, $cart_attr ); |
| 1108 | 1126 | |
| 1109 | 1127 | $content .= '<a ' . $this->get_attribute_string( 'rtsb_add_to_cart_button_' . $id . $rand ) . '>'; |
| @@ -1281,9 +1299,9 @@ | ||
| 1281 | 1299 | * @return void |
| 1282 | 1300 | */ |
| 1283 | 1301 | public function no_products_msg( $metas ) { |
| 1284 | 1302 | $content = |
| 1285 | - '<div class="woocommerce-no-products-found"> | |
| 1303 | + '<div class="rtsb-notice woocommerce-no-products-found"> | |
| 1286 | 1304 | <div class="woocommerce-info">' . esc_html__( 'No products were found matching your selection.', 'shopbuilder' ) . '</div> |
| 1287 | 1305 | </div>'; |
| 1288 | 1306 | |
| 1289 | 1307 | $this->row( $content, $metas ); |