• I have read all the questions but I think there is nothing similar to create an invoice number.
    
    I have noticed that when saving, downloading and emailing the PDF always generates a different consecutive.
    
    How can I do so that both when saving, downloading or sending the invoice always have the same number? Even if the number is included in the PDF
Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter omarcas

    (@omarcas)

    Sorry, I was wrong. It is not an invoice number, it is a quote number. I ask the question again. How can I get a unique quote number to be generated? That is to say that both when saving, sending and downloading are always the same

    Plugin Author David Jensen

    (@dkjensen)

    Hi @omarcas

    This is doable, but it brings about the question what determines if and when a customer should have a new quote number, as opposed to what was generated previously?

    For example if you had a customer generate a quote on a Monday, and then the next days on Tuesday they need another quote, should it generate the same quote number for them?

    Hello; I require the same information; and answering the question @dkjensen in my case I only require the quote number in each new document, regardless of whether the client requests one on Monday and again on Wednesday; in any case it would always be a new one; I would appreciate the timely response.

    Plugin Author David Jensen

    (@dkjensen)

    @j3anscl0 Since this has been requested multiple times, I went ahead and published a new version of the plugin that provides this feature. It can be enabled by navigating to Appearance > Customize > WooCommerce > Cart PDF and checking the box Display unique generated PDF number

    By default it will add the unique PDF number above the date on the PDF, but it can be moved by overriding the cart-table.php file in your child theme.

    If you want to modify the text that displays, for example adding copy before or after the number, you can use the filter wc_cart_pdf_unique_increment_string.

    @dkjensen Thanks for the update. A great feature indeed. It would be great if you can show an example how the below increment string can be achieved?

    JMEP/INV/DATE/UNQUE-REFERENCE

    JMEP/INV/ Are static. Date and unique reference can be dynamic, let say unique reference can be in 10 thousands (10001).

    Appreciate buddy!
    Naz.

    Plugin Author David Jensen

    (@dkjensen)

    @nazreenexe You would do something like:

    add_filter( 'wc_cart_pdf_unique_increment_string', function( $string, $pdf_incrementer ) {
        $string = sprintf( 'JMEP/INV/%s/%s', date( 'Y-m-d' ), sprintf( '%05d', $pdf_incrementer ) ) . '<br>';
    
        return $string;
    }, 10, 2 );

    If you want the increment to start at 10000 go to the wp_options table in database and adjust the meta_key value wc_cart_pdf_unique_increment_num to 10000 as I do not currently have an alternate way to start at a specific number.

    @dkjensen Thanks buddy, work like a charm. Also i just wonder, whether it’s possible to force users to login in order to download the cart (if they are non-logged in users). This becomes pretty obvious in our use-case, as we use the cart pdf as E-Quote.

    Cheers.

    Plugin Author David Jensen

    (@dkjensen)

    @nazreenexe This is possible by simply removing the Download Cart as PDF button if not logged in, or you can keep the button but redirect the user to your login page if they are not logged in. What are your thoughts?

    Well, the second option is ideal where the button can be kept and will be redirected to login. How do i achieve this?

    Plugin Author David Jensen

    (@dkjensen)

    @nazreenexe Try the following:

    remove_action( 'woocommerce_proceed_to_checkout', 'wc_cart_pdf_button', 21 );
    add_action( 'woocommerce_proceed_to_checkout', function() {
        if ( ( ! is_cart() && ! is_checkout() ) || WC()->cart->is_empty() ) {
    		return;
    	}
    
        if ( is_user_logged_in() ) {
    	?>
    
    	<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'cart-pdf' => '1' ), wc_get_cart_url() ), 'cart-pdf' ) ); ?>" class="cart-pdf-button button" target="_blank">
    		<?php echo esc_html( get_option( 'wc_cart_pdf_button_label', __( 'Download Cart as PDF', 'wc-cart-pdf' ) ) ); ?>
    	</a>
    
    	<?php
        } else {
        ?>
    
        <a href="<?php echo esc_url( wp_login_url( wc_get_cart_url() ) ); ?>" class="cart-pdf-button button">
    		<?php echo esc_html( get_option( 'wc_cart_pdf_button_label', __( 'Download Cart as PDF', 'wc-cart-pdf' ) ) ); ?>
    	</a>
    
        <?php
        }
    }, 21 );

    WOW. This is awesome! Great plugin, even great support. one correction above. think wp_login_url takes to the wp login page, instead how do we send to /my-account?

    Thank you so much ????

    • This reply was modified 3 years, 4 months ago by WP Native.
    Plugin Author David Jensen

    (@dkjensen)

    @nazreenexe Appreciate the kind words. The url would be

    <?php echo esc_url( home_url( '/my-account/' ) ); ?>

    @dkjensen Thank you once again. We do operate an e-comm website which is exclusively for building materials. Most of our customers are companies and they need a quotation as a part of their procurement process. This plugin literally saved us in that context where customer themself can generate quote. Thank you so much for making this free and we will be the first to support you if you launch this commercially.

    Thanks,
    Nazreen.

    Plugin Author David Jensen

    (@dkjensen)

    @nazreenexe I’m glad to hear that, thank you!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Create an invoice number’ is closed to new replies.