• Resolved resixe

    (@artml)


    Hi and thanks for this great plugin,

    Is there a way to increase invoice number for all sites in multisite installation? The main objective is increase the wcpdf_invoice_number table for all sites when a new invoice is generated. If possible, I would also like to sync the “next invoice number” edit field, in order that saving the value on one site stores the new value for all sites.

    Thanks for your attention

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi!
    The number store is currently a per-site table, using the table prefix from $wpdb->prefix. This was hardcoded, but I have just committed an update to our development version that allows for using a custom table name with the filter wpo_wcpdf_number_store_table_name.
    Here’s an example that would use the central table prefix instead of the site prefix on a multisite installation:

    
    add_filter( 'wpo_wcpdf_number_store_table_name', 'wpo_wcpdf_number_store_table_name', 10, 3 );
    function wpo_wcpdf_number_store_table_name( $table_name, $store_name, $method ) {
    	global $wpdb;
    	return "{$wpdb->base_prefix}_wcpdf_{$store_name}";
    }
    

    I haven’t tested the above filter, as I don’t have a multisite setup here, and naturally this would require the latest development version from github (master branch).
    https://github.com/wpovernight/woocommerce-pdf-invoices-packing-slips

    There’s no need to ‘sync’ anything with this approach, as it will then just use one central database table.

    Hope that helps!
    Ewout

    Thread Starter resixe

    (@artml)

    Wow, that was great! Of course it helps, you have absolutely solved my problem!

    You have my five stars for sure, thanks!

    soudainm

    (@soudainm)

    Hello

    I use this plugin for some time and I find it great!

    I think I have encountered the same problem as mentioned above, however I can not solve it.

    I spent my multisite site with the Woocommerce Multistore plugin.
    I have a main site (pechola.fr) and a secondary site (site A).
    I would like that, when an order is placed on the site A, the invoice is the following one of Pechola.fr
    Thus, if the current order is the number 407 on pechola.fr, the next order placed on site A will be order number 408.

    Thank you for your attention,
    Mike

    Thread Starter resixe

    (@artml)

    I’m not sure if I can help you, I’m not using Woocommerce Multistore, just standard Woocommerce in two different sites (WP multisite), but all I did to get the same that you are looking for was install and activate the development version of this plugin and use the filter that @pomegranate wrote above. And works great to me in WP 4.9.4

    Good luck!

    soudainm

    (@soudainm)

    Hello, thank you for your answer !

    you use the free or paid version of “PDF Invoices???

    I’m not good at developing, can you tell me the steps to follow to succeed as you please?

    Plugin Contributor kluver

    (@kluver)

    Hi @soudainm,

    It is no longer necessary to download the development version. The functionality is now in the latest version (2.1.5) of our plugin. So just update and you should be good to go! ??

    With kind regards,

    Michael

    soudainm

    (@soudainm)

    Hello,

    I have to miss something in my configuration because I can not make it work like that.

    I have to install the plugin on the network, on the main site or on both sites?

    Thanks for your help

    Plugin Contributor Ewout

    (@pomegranate)

    The plugin should be active on both sites if you want to generate invoices on both ??

    You will still need that filter though!

    
    add_filter( 'wpo_wcpdf_number_store_table_name', 'wpo_wcpdf_number_store_table_name', 10, 3 );
    function wpo_wcpdf_number_store_table_name( $table_name, $store_name, $method ) {
    	global $wpdb;
    	return "{$wpdb->base_prefix}_wcpdf_{$store_name}";
    }
    

    If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters

    Ewout

    soudainm

    (@soudainm)

    Hello, I’m coming to give you news ??

    That’s it all works so thank you very much for your help!

    The bug was due to an “_” in excess.

    {$wpdb->base_prefix}_wcpdf_{$store_name}

    remplacé par :

    {$wpdb->base_prefix}wcpdf_{$store_name}

    Thanks again for your help and go for a five star ??

    Plugin Contributor Ewout

    (@pomegranate)

    Thanks for the heads-up! I think either should work, you would just have an additional underscore. Your solution is more elegant. Glad to hear it all works now, looking forward to your review ;)!

    Ewout

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Multisite: Increase invoice number’ is closed to new replies.