• Resolved lawkwok

    (@lawkwok)


    Hi,

    We are using the WooCommmerce Stripe plugin, and when a transaction is created, the Stripe dashboard shows a description for each order “Store Name – Order XXXX”. However, after the update 2.0.0 (or a few versions thereafter) the order number stopped showing up. How do I get the order number to appear again?

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor kluver

    (@kluver)

    Hi @lawkwok,

    Is the order number no longer appearing in your invoices or in the Stripe Dashboard? The Stripe Dashboard is rendered by the WooCommerce Stripe plugin. That is not our plugin. So there is nothing we can do about that.

    If you are having trouble showing a custom field on your generated invoices could you please show me in what way you are adding this custom field to your invoice? Then I have a better idea of what the problem could be.

    With kind regards,

    Michael

    Plugin Contributor Ewout

    (@pomegranate)

    @lawkwok, in addition to Michael’s question, can you clarify whether you are referring to the invoice number or the order number? Your subject is referring to invoice number, but everything else is referring to the order number. In a standard workflow, there would not be an invoice number before the order is paid, so that would make it more likely that it would be the order number. The PDF invoice plugin does not actively send the PDF Invoice number to the stripe plugin and didn’t do that in the past either, so I’m not sure where this used to come together – possibly there was some custom code involved too?

    Any additonal information that you have that may help to solve this issue would be more than welcome ??
    Ewout

    Thread Starter lawkwok

    (@lawkwok)

    Sorry, I am referring to the sequential invoice number generated by WooCommerce PDF Invoices & Packing Slips.

    There is this related code in WooCommerce’s Stripe plugin in class-wc-gateway-stripe.php:331
    $post_data['description'] = sprintf( __( '%s - Order %s', 'woocommerce-gateway-stripe' ), wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ), $order->get_order_number() );

    I am also using the following code to generate an invoice number when an order comes in (orders are put on-hold because we don’t capture funds until we ship)

    add_action( 'woocommerce_order_status_on-hold', 'wpo_wcpdf_create_invoice_number' );
    function wpo_wcpdf_create_invoice_number ( $order_id ) {
    	$order = wc_get_order( $order_id );
    	$invoice = wcpdf_get_document( 'invoice', $order, true );
    }

    My guess is that the order number does not get generated at the right time which is why it does not get passed to the Stripe plugin?

    Plugin Contributor kluver

    (@kluver)

    Hi @lawkwok,

    There is a difference between the invoice number and the order number. The order number is created by WooCommerce and then send to Stripe. The invoice number is created through our plugin and never gets send to stripe.

    So what in the past showed up in your Stripe Dashboard was the order number. Again, this is created by WooCommerce and send to Stripe with the WooCommerce Stripe plugin. Our plugin is never involved in this process, so unfortunately we can not help you fix the problem.

    I would advise you to contact the developers of the WooCommerce Stripe plugin and ask them why the order number is no longer showing up in your Stripe Dashboard.

    I hope this answers your question.
    Have a great day!

    With kind regards,

    Michael

    Thread Starter lawkwok

    (@lawkwok)

    I think I found the problem. Because order numbers are no longer stored in post_meta this code to globally filter the order number to use this plugin’s invoice number.

    I tried updating

    $invoice_number = get_post_meta( $order->id, '_wcpdf_invoice_number', true);

    to
    $invoice_number = $wpdb->get_results( "SELECT id FROM wp_wcpdf_invoice_number WHERE order_id = $order_id" );

    But it doesn’t work ?? It would be awesome to have an option to globally change invoice numbers. Is there an updated snippet that you recommend that works best with WooCommerce PDF Invoices & Packing Slips v2.x?

    • This reply was modified 7 years, 1 month ago by lawkwok.
    • This reply was modified 7 years, 1 month ago by James Huff.
    Plugin Contributor Ewout

    (@pomegranate)

    Ah, now it all makes sense – I did not know you used the invoice number as order number!

    The invoice number is certainly still saved in postmeta. If you want to use the formatted invoice number as order number, it’s super simple:

    
    add_filter( 'woocommerce_order_number', 'woocommerce_invoice_order_number', 99, 2);
    function woocommerce_invoice_order_number( $order_number, $order ) {
    	if ( $invoice_number = $order->get_meta('_wcpdf_invoice_number') ) {
    		$order_number = $invoice_number;
    	}
    
    	return $order_number;
    }
    

    More advanced snippet if you want to use the order number getters (for example to use the unformatted invoice number):

    
    add_filter( 'woocommerce_order_number', 'woocommerce_invoice_order_number', 99, 2);
    function woocommerce_invoice_order_number( $order_number, $order ) {
    	$invoice = wcpdf_get_invoice( $order );
    	if ( $invoice && $invoice->exists() ) {
    		if ( $invoice_number = $invoice->get_number() ) {
    			// $formatted_invoice_number = $invoice_number->get_formatted();
    			$plain_invoice_number = $invoice_number->get_plain();
    			$order_number = $plain_invoice_number;
    		};
    	}
    
    	return $order_number;
    }
    

    Ewout

    Thread Starter lawkwok

    (@lawkwok)

    As always, thank you, Ewout!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Invoice number not appearing in Stripe description’ is closed to new replies.