File tree Expand file tree Collapse file tree 1 file changed +3
-29
lines changed Expand file tree Collapse file tree 1 file changed +3
-29
lines changed Original file line number Diff line number Diff line change 11<?php
22/**
3- * Gravity Perks // Conditional Pricing // Add Support for Choice-based Rules with WPML Translations
4- * https://gravitywiz.com/documentation/gravity-forms-conditional-pricing/
3+ * We're no longer using the experimental folder for experimental snippets. 🚧
4+ * You can now find the snippet here:
5+ * https://github.com/gravitywiz/snippet-library/blob/master/gp-conditional-pricing/gpcp-wpml-support.php
56 */
6- add_filter ( 'gpcp_pricing_logic ' , function ( $ pricing_logic , $ form ) {
7-
8- if ( isset ( $ GLOBALS ['wpml_gfml_tm_api ' ] ) ) {
9- /**
10- * GPCP fetches the pricing logic at several points during the page load. We need to translate our pricing
11- * rules *before* WPML has translated the form. Otherwise, choice-based conditions will not return a
12- * translation match since the original choice has already been translated. This is relevant to the
13- * Gravity_Forms_Multilingual::translate_conditional_logic() call below.
14- */
15- static $ wpml_pricing_logic ;
16- if ( isset ( $ wpml_pricing_logic [ $ form ['id ' ] ] ) ) {
17- return $ wpml_pricing_logic [ $ form ['id ' ] ];
18- }
19- foreach ( $ pricing_logic as &$ field_pricing_logic ) {
20- /**
21- * WPML's translate_conditional_logic() method only translates the "fields" and "notifications" section
22- * and it needs the "fields" section to look up fields for conditional logic so... we use "notifications".
23- */
24- $ form ['notifications ' ] = $ field_pricing_logic ;
25- $ form = $ GLOBALS ['wpml_gfml_tm_api ' ]->translate_conditional_logic ( $ form );
26- $ field_pricing_logic = $ form ['notifications ' ];
27- }
28- $ wpml_pricing_logic [ $ form ['id ' ] ] = $ pricing_logic ;
29- }
30-
31- return $ pricing_logic ;
32- }, 10 , 2 );
You can’t perform that action at this time.
0 commit comments