• Resolved Andrea

    (@licoreo)


    Hello,
    I am using this plugin and it works very well, but I have a problem with the invoice creation button:
    I would like to completely disable the manual creation as I have imposted the creation of invoices at the status order “completed”.
    So I’m looking for a way to initially disable the button of invoice in order list and order detail, and having it enabled only when the status is changed to “completed” so to allow the admin to see the invoice created.
    Is it possible?

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

    (@kluver)

    Hi @licoreo,

    Yes this is certainly possible. You can unset these buttons when an order is not yet set to completed with the following code snippets:

    // Only show PDF invoice action button on completed order
    add_filter( 'wpo_wcpdf_listing_actions', 'wpo_wcpdf_hide_invoice_button_untill_order_completed', 10, 2 );
    function wpo_wcpdf_hide_invoice_button_untill_order_completed( $listing_actions, $order ) {
        if ($order->get_status() !== 'completed') {
            unset($listing_actions['invoice']);
        }
        return $listing_actions;
    }
    
    // Only show PDF invoice button in meta box on completed order
    add_filter( 'wpo_wcpdf_meta_box_actions', 'wpo_wcpdf_hide_meta_box_invoice_button_untill_order_completed', 10, 2);
    function wpo_wcpdf_hide_meta_box_invoice_button_untill_order_completed ($meta_box_actions, $post_id) {
        $order = wc_get_order( $post_id );
        if ($order->get_status() !== 'completed') {
            unset($meta_box_actions['invoice']);
        }
        return $meta_box_actions;
    }

    You should place these snippets in the functions.php of your child-theme. If you haven’t worked with code snippets or functions.php before please read this: How to use filters

    I hope this helps!

    Thread Starter Andrea

    (@licoreo)

    it works perfectly, many thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘disable button create’ is closed to new replies.