Skip to content

Commit 4ac1c90

Browse files
authored
gpecf-set-discount-amount-via-gpep.php: Migrated.
1 parent e21b59b commit 4ac1c90

File tree

1 file changed

+3
-36
lines changed

1 file changed

+3
-36
lines changed
Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,6 @@
11
<?php
22
/**
3-
* Gravity Perks // GP eCommerce Fields // Dynamically Set Discount Amount via Easy Passthrough
4-
* http://gravitywiz.com/documentation/gravity-forms-ecommerce-fields/
5-
*
6-
* This experimental snippet allows you to set the discount amount by a field that has been populated via Easy Passthrough.
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-ecommerce-fields/gpecf-set-discount-amount-via-gpep.php
76
*/
8-
// Update "123" to your form ID.
9-
add_filter( 'gform_pre_render_123', 'gw_set_discount_amount' );
10-
add_filter( 'gform_pre_process_123', 'gw_set_discount_amount' );
11-
add_filter( 'gform_admin_pre_render_123', 'gw_set_discount_amount' );
12-
function gw_set_discount_amount( $form ) {
13-
14-
if ( current_filter() === 'gform_admin_pre_render_' . $form['id'] && GFForms::get_page() !== 'entry_detail' ) {
15-
return $form;
16-
}
17-
18-
foreach ( $form['fields'] as &$field ) {
19-
// Update "5" to your Discount field ID.
20-
if ( $field->id == 3 ) {
21-
// Update "6" to the field that will be populated by Easy Passthrough with the discount amount.
22-
$field->discountAmount = gw_get_gpep_value( $form['id'], 6 );
23-
}
24-
}
25-
26-
return $form;
27-
}
28-
29-
function gw_get_gpep_value( $form_id, $field_id ) {
30-
31-
if ( GFForms::get_page() && rgget( 'lid' ) ) {
32-
$entry = GFAPI::get_entry( rgget( 'lid' ) );
33-
$field_values = $entry;
34-
} else {
35-
$field_values = gp_easy_passthrough()->get_field_values( $form_id );
36-
}
37-
38-
return rgar( $field_values, $field_id );
39-
}

0 commit comments

Comments
 (0)