File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Gravity Shop // GS Product Configurator // Move validation errors to be directly above product Gravity Form.
4+ * https://gravitywiz.com/documentation/gravity-shop-product-configurator/
5+ *
6+ * By default, Gravity Shop Product Configurator will display validation errors at the very top of the form used
7+ * to configure a product. This means it would be above any variations and other controls provided by WooCommerce
8+ * and other WooCommerce extensions.
9+ *
10+ * Instructions:
11+ * Install per https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
12+ */
13+ add_filter ( 'gform_get_form_filter ' , function ( $ markup , $ form ) {
14+ if ( ! function_exists ( 'gs_product_configurator ' ) || ! gs_product_configurator ()->should_enqueue_frontend ( $ form ) ) {
15+ return $ markup ;
16+ }
17+
18+ $ pattern = '/<div class="gform_validation_errors" ([\s\S]+?)<\/div>/ ' ;
19+ $ pattern2 = '/(<div class=([" \'])gform[-_]body)/ ' ;
20+ if ( preg_match ($ pattern , $ markup , $ matches ) ) {
21+ $ markup = preg_replace ( $ pattern , '' , $ markup );
22+ $ markup = preg_replace ( $ pattern2 , $ matches [0 ] . '$1 ' , $ markup );
23+ }
24+ return $ markup ;
25+ }, 10 , 2 );
You can’t perform that action at this time.
0 commit comments