• Resolved tomqispi

    (@tomqispi)


    Hi,

    I use this good plugin in combination with “Deposits & Partial Payments for WooCommerce” which allow to pay only a deposit instead of the full amount.
    In the order details, there is a panel “Partial payment details” with information like :
    ID Payment Payment method Amount Status
    3068-1 Deposit PayPal 42,24€ Terminée
    3068-2 Future payment 63,36€ Attente paiement

    In the pdf invoice, there is the details of the Deposit and the Future Payment, but there is no information about the Payment method.

    Whereas the deposit is paid or not, the invoice is the same…

    Is it possible to display the payment method and the amount already paid?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hi @tomqispi

    Because that plugin creates child orders for the deposits and the payment method is stored there, you need to add the code snippet below:

    add_filter( 'wpo_wcpdf_payment_method', function( $method, $document ) {
    	if ( ! empty( $document ) && ! empty( $order = $document->order ) && $document->get_type() == 'invoice' ) {
    		$args = array(
    			'post_type'   => AWCDP_POST_TYPE,
    			'post_parent' => $order->get_id(),
    			'post_status' => 'any',
    			'numberposts' => -1,
    		);
    
    		$payments = wc_get_orders( $args );
    		$methods  = array();
    		foreach ( $payments as $payment_order ) {
    			$data = $payment_order->get_data();
    			if ( ! empty( $data['payment_method_title'] ) ) {
    				$methods[] = sanitize_text_field( $data['payment_method_title'] );
    			}
    		}
    
    		$method = implode( ',', $methods );
    		
    	}
    	return $method;
    }, 10, 2 );

    Let me know.

    Thread Starter tomqispi

    (@tomqispi)

    Hi @alexmigf

    Thank you for this tip. Now the Payment method is written on the invoice, much better ??

    But there is still a problem : whatever the status the Payment method is written. Even if the status is “pending payment”. For example when the user choose a payment method, go to the payment gateway but don’t validate it (for technical or personal reason) : the payment method is registered (and displayed on the invoice) but not payment is received.

    Is it possible to display either the order status or (better) the amount really already payed?

    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @tomqispi

    I added a new check for the order, $order->is_paid(), see below:

    add_filter( 'wpo_wcpdf_payment_method', function( $method, $document ) {
    	if ( ! empty( $document ) && ! empty( $order = $document->order ) && $document->get_type() == 'invoice' && $order->is_paid() ) {
    		$args = array(
    			'post_type'   => AWCDP_POST_TYPE,
    			'post_parent' => $order->get_id(),
    			'post_status' => 'any',
    			'numberposts' => -1,
    		);
    
    		$payments = wc_get_orders( $args );
    		$methods  = array();
    		foreach ( $payments as $payment_order ) {
    			$data = $payment_order->get_data();
    			if ( ! empty( $data['payment_method_title'] ) ) {
    				$methods[] = sanitize_text_field( $data['payment_method_title'] );
    			}
    		}
    
    		$method = implode( ',', $methods );
    		
    	}
    	return $method;
    }, 10, 2 );
    Thread Starter tomqispi

    (@tomqispi)

    Perfect @alexmigf ?? ! Thank you!

    I just change a little the code to adapt it to what I exactly want :

    add_filter( 'wpo_wcpdf_payment_method', function( $method, $document ) {
    	if ( ! empty( $document ) && ! empty( $order = $document->order ) && $document->get_type() == 'invoice' && ( $order->is_paid() || $order->has_status('partially-paid') ) ) {
    		$args = array(
    			'post_type'   => AWCDP_POST_TYPE,
    			'post_parent' => $order->get_id(),
    			'post_status' => 'any',
    			'numberposts' => -1,
    		);
    
    		$payments = wc_get_orders( $args );
    		$methods  = array();
    		foreach ( $payments as $payment_order ) {
    			$data = $payment_order->get_data();
    			if ( ! empty( $data['payment_method_title'] ) ) {
    				$methods[] = sanitize_text_field( $data['payment_method_title'] );
    			}
    		}
    
    		$method = implode( ',', $methods );
    		
    	}
    	return $method;
    }, 10, 2 );
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Payments display with “Deposits & Partial Payments for WooCommerce”’ is closed to new replies.