• Hi all,

    I want to add some code using the edd_complete_purchase hook. But in which functions.php do i need to add the hook? There are so many.

    Thanks in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @jack85nl

    You can put the code in your theme functions.php file. You can find this file in your theme root folder.

    e.g /wp-content/themes/twentytwenty/functions.php

    Thread Starter jack85nl

    (@jack85nl)

    Hi @pratik-jain

    Thanks for responding to my question. All-though it doesn’t seems to trigger my echo on the purchase-confirmation page (echo is just for testing). I placed the follow code into the functions.php of my theme.

    function pw_edd_on_complete_purchase( $payment_id ) {
    
    $connections= $payment->total * '100';                
    $entry_date= date('Y-d-m H:i:s');  
    
    echo 'Payment was succesful! Amount: '. $connections . 'PaymentID: '. $payment_id;
    
    }
    add_action( 'edd_complete_purchase', 'pw_edd_on_complete_purchase' );

    Any idea’s?

    Hi @jack85nl

    Sorry for my late response. Actually you are using $payment but you have not taken it as function parameter.

    This action will run only first time. I mean for new payments only.

    Also put exit after echo so you can see the text and understand the process.

    function pw_edd_on_complete_purchase( $payment_id, $payment, $customer ) {
    
    $connections= $payment->total * '100';                
    $entry_date= date('Y-d-m H:i:s');  
    
    echo 'Payment was successful! Amount: '. $connections . 'PaymentID: '. $payment_id;
    exit;
    }
    add_action( 'edd_complete_purchase', 'pw_edd_on_complete_purchase', 10, 3 );

    I hope this will work for you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘functions.php > edd_complete_purchase hook’ is closed to new replies.