• Resolved Rahim

    (@rahimvaziri)


    Hi @skyverge,
    Hope you are doing very well.

    First of all thank you so much for the plugin.

    I have an invoice plugin.
    In this plugin there is a section which says the order details :

    protected function get_invoice_info( $order_id ) {
    		$invoice_prefix = get_option( 'wc_wip_settings_invoice_prefix' ) ? get_option( 'wc_wip_settings_invoice_prefix' ) . '-' : '';
    		$invoice_suffix = get_option( 'wc_wip_settings_invoice_suffix' ) ? '-' . get_option( 'wc_wip_settings_invoice_suffix' ) : '';
    		$invoice_start  = get_option( 'wc_wip_settings_invoice_start' ) ? get_option( 'wc_wip_settings_invoice_start' ) : 0;
    		$invoice_number = $invoice_prefix . ( $invoice_start + $order_id ) . $invoice_suffix;
    		$invoice_date   = date_i18n( 'Y/m/d H:i', time() );

    I couldn’t override the order number via your help in the description.
    Could you please help me to change the order number in the codes of the invoice plugin?

    Regards,
    Rahim

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor tamarazuk

    (@tamarazuk)

    Hey Rahim,

    Thanks for getting in touch! I’m happy to help you here ??

    Your code should be modified to use the order number instead of the order ID. Something like this should work:

    
    $order = wc_get_order( $order_id );
    $order_number = $order instanceof WC_Order ? $order->get_order_number() : $order_id;
    

    I would highly recommend getting in touch with the developers of the invoice plugin to make this change directly in the plugin so you can safely update the plugin in the future.

    I hope this helps! Are there any other questions I can help you with?

    Cheers,

    Tamara

    Thread Starter Rahim

    (@rahimvaziri)

    Thank you

    I couldn’t fix the issue.
    I also unfortunately I don’t have access to the Author.

    This is the whole code of this section:

    protected function get_invoice_info( $order_id ) {
    
    		date_default_timezone_set( 'Asia/Tehran' );
    
    		$invoice_prefix = get_option( 'wc_wip_settings_invoice_prefix' ) ? get_option( 'wc_wip_settings_invoice_prefix' ) . '-' : '';
    
    		$invoice_suffix = get_option( 'wc_wip_settings_invoice_suffix' ) ? '-' . get_option( 'wc_wip_settings_invoice_suffix' ) : '';
    
    		$invoice_start  = get_option( 'wc_wip_settings_invoice_start' ) ? get_option( 'wc_wip_settings_invoice_start' ) : 0;
    
    		$invoice_number = $invoice_prefix . ( $invoice_start + $order_id ) . $invoice_suffix;
    
    		$invoice_date   = date_i18n( 'Y/m/d H:i', time() );
    
    		return array(
    
    			'invoice_number' => $invoice_number,
    
    			'invoice_date'   => $invoice_date,
    
    		);
    
    	}

    If it’s fixable, could you please give me the final code?

    Lots of thanks,
    Rahim

    Plugin Author SkyVerge

    (@skyverge)

    Hi Rahim,

    As I’m not at all familiar with that plugin, I can’t give you more guidance other than what was already provided. I would recommend reaching out to that plugin’s developer with a link to my answer above as well as a link to the plugin’s main page, which also discusses compatibility in the FAQ question. The Invoice plugin’s developer would best know how to make the required changes.

    I hope that helps. Could I help with any other questions?

    Cheers,
    Tamara

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Order Number Help’ is closed to new replies.