• Resolved truqmedia

    (@truqmedia)


    Hello and thanks for a useful plugin,

    The plugin works fine for what we want it to do, which is generate an invoice PDF upon order completion (and append a two page PDF to that invoice).

    This is the only PDF we need. Email only is enough for refunds.

    When I refund an order, I get a blank page. If I access the backend by tying its address in the address bar, I see that the order was refunded correctly. Refund email is being sent and received normally. So everything seems to be working, except for the fact that I get a blank page after changing order status to “refunded” instead of being taken back to the order page.

    In the log I get the following error:

    2018-08-30T17:58:49+00:00 CRITICAL Uncaught Error: Call to undefined method WC_Order_Refund::get_order_number() in /home/2/s/slankemat/shop/wp-content/plugins/woocommerce-pdf-invoices/includes/abstracts/abstract-invoice.php:231
    Stack trace:
    #0 /home/2/s/slankemat/shop/wp-content/plugins/woocommerce-pdf-invoices-premium/includes/class-credit-note.php(531): BEWPI_Abstract_Invoice->get_next_invoice_number()
    #1 /home/2/s/slankemat/shop/wp-content/plugins/woocommerce-pdf-invoices-premium/includes/class-credit-note.php(355): BEWPIP_Credit_Note->generate()
    #2 /home/2/s/slankemat/shop/wp-includes/class-wp-hook.php(286): BEWPIP_Credit_Note::generate_credit_note_for_refund(217, 228)
    #3 /home/2/s/slankemat/shop/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array)
    #4 /home/2/s/slankemat/shop/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
    #5 /home/2/s/slankemat/shop/wp-content/plugins/woocommerce/includes/wc-order-functions.php(598): do_action('woocommerce_ord...', 217, 228)
    #6 /home/2/s/slankemat/shop/wp-content/plugins/woocommerc

    It seems it’s failing while trying to generate a credit note, but I don’t need one.

    I am using a custom template in uploads/woocommerce-pdf-invoices/templates/invoice/simple but it is working fine when generating the regular invoice.

    Possibly relevant: my custom PDF template’s header includes the following code (We wanted the order info in the header). It’s not causing any problems when generating the regular invoices, though.

    <td>
    			<?php
    			printf( __( 'Ordrenummer: %s', 'woocommerce-pdf-invoices' ), $invoice->get_formatted_number() );
    			printf( '<br />' );
    			printf( __( 'Bestillingsdato: %s', 'woocommerce-pdf-invoices' ), $invoice->get_formatted_order_date() );
    			printf( '<br />' );
    			printf( __( 'Bestillingsnummer: %s', 'woocommerce-pdf-invoices' ), $order->get_order_number() );
    
    			if ( $payment_gateway ) {
    				printf( '<br />' );
    				printf( __( 'Betalingsm?te: %s', 'woocommerce-pdf-invoices' ), $payment_gateway->get_title() );
    
    				// Get PO Number from 'WooCommerce Purchase Order Gateway' plugin.
    				if ( 'woocommerce_gateway_purchase_order' === $payment_gateway->get_method_title() ) {
    					$po_number = $templater->get_meta( '_po_number' );
    					if ( $po_number ) {
    						printf( '<br />' );
    						printf( __( 'Purchase Order Number: %s', 'woocommerce-pdf-invoices' ), $po_number );
    					}
    				}
    			}
    
    			// Get VAT Number from 'WooCommerce EU VAT Number' plugin.
    			$vat_number = $templater->get_meta( '_vat_number' );
    			if ( $vat_number ) {
    				printf( '<br />' );
    				printf( __( 'VAT Number: %s', 'woocommerce-pdf-invoices' ), $vat_number );
    			}
    			?>
    		</td>
    • This topic was modified 6 years, 6 months ago by truqmedia.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter truqmedia

    (@truqmedia)

    Update:

    So as I said I suspect the mistake lies in my own custom templates for the PDF invoice, but since the error only becomes problematic when generating credit notes, and since I don’t need credit notes, I just solved the problem by disabling credit notes altogether.

    Added to functions.php:

    add_action( 'admin_init', 'remove_credit_note_generation' );
    function remove_credit_note_generation() {
    	remove_action ( 'woocommerce_order_refunded', array( 'BEWPIP_Credit_Note', 'generate_credit_note_for_refund' ), 10, 2 );
    }
    Plugin Author Bas Elbers

    (@baaaaas)

    Hi,

    Thanks for letting me know you’ve fixed it!
    Next time please use our contact page since you are using our premium plugin. I will be able to support you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Blank page on refund’ is closed to new replies.