Last active
May 31, 2023 01:42
-
-
Save geekontheroad/39fd19fb9414b2ed733942c6a84ba1e4 to your computer and use it in GitHub Desktop.
GF coinbase commerce change transaction id mergetag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Snippet for Coinbase Commerce for gravity forms | |
* This will replace the value of the transaction id mergetag with the value of the cc_order_id meta | |
* | |
* INSTRUCTIONS | |
* Copy this to your functions.php of your child theme. Use a code snippets plugin if you dont have the child theme | |
* Make sure to omit the <?php tag when copying to functions.php | |
* | |
* @return string $text | |
* @author geekontheroad | |
* @link https://geekontheroad.com/coinbase-commerce-for-gravity-forms | |
***/ | |
add_filter( 'gform_pre_replace_merge_tags', function ( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format ) { | |
$merge_tag = '{transaction_id}'; | |
if ( strpos( $text, $merge_tag ) === false || empty( $form ) || empty( $entry ) ) { | |
return $text; | |
} | |
$transaction_id = esc_html( rgar( $entry, 'cc_order_id' ) ); | |
return str_replace( $merge_tag, $url_encode ? urlencode( $transaction_id ) : $transaction_id, $text ); | |
}, 10, 7 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment