• Resolved ojasya

    (@ojasya)


    How can I hook the following code in the following hook (give_update_payment_status) via add_action

    For now I am doing by editing the original code in the file plugins\give\includes\payments\class-give-payment.php”
    but writing the following code.

    do_action( 'give_update_payment_status', $this->ID, $status, $old_status );
    
    if($status=="publish"){
    	if($this->form_id==235){
    		$balance = get_field('balsance',235);
    		$balance = $balance + $this->subtotal;
    		update_field('balance', $balance, 235); 
    	}elseif ($this->form_id==62) {
    		$balance = get_field('balance',235);
    		if($balance>= $this->subtotal){
    			$balance = $balance - $this->subtotal;
    		}else{
    			$balance = 0;
    		}					
    		update_field('balance', $balance, 235);
    		$state_data = get_field('state_data',$this->form_id);
    		update_field('state_data',$this.'ss1' , $this->form_id);	
    	}else{
    
    	}		
    
    }

    So can you please assist me with this please ..

    Also how can I access the custom form fields inside above code

    I know this might not be in the scope of support but can you pleas please help me on this

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Rick Alday

    (@mrdaro)

    Hi @ojasya,

    Right now, we do not have documentation that covers how to customize GiveWP to this extent, with all the hooks that you can use to change it.

    The give_update_payment_status action runs ONLY after a status has been updated, which happens on a successful donation from any gateway. So in your function, you don’t need the if statement to check if the donation has a status of publish because it does have that status alredy.

    Just proceed with the rest of the logic.

    function your_function( $donation_id, $new_status, $old_status ) {
        your code here
    }
    add_action( 'give_update_payment_status', 'your_function', 200, 3 );
    

    Note: we provide custom code snippets to our customers as a courtesy to extend current functionality. These are not tested with each GiveWP release, so we can’t officially provide support for them. Also, custom solutions like this fall outside of the scope of support. You possibly need to check GiveWP’s code and see how to integrate it with custom solutions. You can also ask a question directly to our developers here https://github.com/impress-org/givewp/discussions and read this https://github.com/impress-org/givewp/discussions/5816 before posting a question to make sure you get the best answer from them.

    Thread Starter ojasya

    (@ojasya)

    @mrdaro

    Thanks a lot for your reply.

    But since I am running logic based on the form id

    there is no way to get the form id

    is there a way to get the form id from donation id ?

    Thread Starter ojasya

    (@ojasya)

    @mrdaro

    Ok I got it.

    $meta = give_get_meta( $donation_id );
    $form_id = $meta["_give_payment_form_id"][0];

    Sorry for bothering you

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to hook function to action’ is closed to new replies.