Last active
January 12, 2020 21:03
-
-
Save jdeeburke/f7a050c86505e03943d55a1a5ef97282 to your computer and use it in GitHub Desktop.
Jilt for EDD Manual Payments Compatibility Snippet
This file contains hidden or 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 | |
// Add this to your theme's functions.php file or use a plugin | |
// like Code Snippets - https://wordpress.org/plugins/code-snippets/ | |
add_action( 'edd_payment_saved', function( $payment_id, $payment ) { | |
// EDD Manual Payment callback | |
if ( doing_action( 'edd_create_payment' ) ) { | |
if ( ! $payment->get_meta( '_edd_jilt_cart_token' ) ) { | |
// Generate cart token (also assigns to user session) | |
$cart_token = edd_jilt()->get_cart_handler()->get_cart_token(); | |
// Add cart tokent to the manual payment | |
$payment->update_meta( '_edd_jilt_cart_token', $cart_token ); | |
// Remove the cart token from the current user's session | |
EDD_Jilt_Session::unset_jilt_order_data(); | |
} | |
} | |
}, 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment