{"id":108,"date":"2017-08-25T10:19:14","date_gmt":"2017-08-25T10:19:14","guid":{"rendered":"https:\/\/wpinvoicing.com\/docs\/?p=108"},"modified":"2019-11-16T10:25:46","modified_gmt":"2019-11-16T10:25:46","slug":"wpinv_update_status","status":"publish","type":"docs","link":"https:\/\/wpgetpaid.com\/docs\/developers\/wpinv_update_status\/","title":{"rendered":"wpinv_update_status"},"content":{"rendered":"<p>Fires after an invoice status has been changed from one status to another.<\/p>\n<p><pre><code>do_action( 'wpinv_update_status', int $invoice_id, string $new_status, string $old_status );<\/code><\/pre>\n<\/p>\n<p class=\"clearfix\">\n<h4 id=\"parameters\">Parameters <a href=\"#parameters\" class=\"anchor\"><span aria-hidden=\"true\">#<\/span><\/a><\/h4>\n<dl>\n<dt>$invoice_id<\/dt>\n<dd>\n<p class=\"desc\"><span class=\"type\">(<span class=\"int\">int<\/span>) <\/span><span class=\"description\">The Invoice ID.<\/span><\/p>\n<\/dd>\n<dt>$new_status<\/dt>\n<dd>\n<p class=\"desc\"><span class=\"type\">(<span class=\"string\">string<\/span>) <\/span><span class=\"description\">Invoice new status. <a href=\"https:\/\/wpinvoicing.com\/docs\/about-different-invoice-statuses\/\" target=\"_blank\" rel=\"noopener noreferrer\">Learn more<\/a><\/span><\/p>\n<\/dd>\n<dt>$old_status<\/dt>\n<dd>\n<p class=\"desc\"><span class=\"type\">(<span class=\"string\">string<\/span>) <\/span><span class=\"description\">Invoice old status. <a href=\"https:\/\/wpinvoicing.com\/docs\/about-different-invoice-statuses\/\" target=\"_blank\" rel=\"noopener noreferrer\">Learn more<\/a><\/span><\/p>\n<\/dd>\n<\/dl>\n<h4 id=\"examples\">Examples <a href=\"#examples\" class=\"anchor\"><span aria-hidden=\"true\">#<\/span><\/a><\/h4>\n<p>Simple example to handle invoice status has been changed.<\/p>\n<pre>function _wpi_wpinv_update_status( $invoice_id, $new_status, $old_status ) {\r\n    \/\/ Invoice object\r\n    $invoice = wpinv_get_invoice( $invoice_id );\r\n\r\n    \/\/ Invoice items\r\n    $cart_items = $invoice->get_cart_details();\r\n\r\n    \/\/ Do your stuff here\r\n}\r\nadd_action( 'wpinv_update_status', '_wpi_wpinv_update_status', 10, 3 );<\/pre>\n","protected":false},"featured_media":0,"parent":241,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","doc_tag":[],"amp_validity":null,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/wpgetpaid.com\/docs\/wp-json\/wp\/v2\/docs\/108"}],"collection":[{"href":"https:\/\/wpgetpaid.com\/docs\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/wpgetpaid.com\/docs\/wp-json\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/wpgetpaid.com\/docs\/wp-json\/wp\/v2\/comments?post=108"}],"version-history":[{"count":0,"href":"https:\/\/wpgetpaid.com\/docs\/wp-json\/wp\/v2\/docs\/108\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/wpgetpaid.com\/docs\/wp-json\/wp\/v2\/docs\/241"}],"wp:attachment":[{"href":"https:\/\/wpgetpaid.com\/docs\/wp-json\/wp\/v2\/media?parent=108"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/wpgetpaid.com\/docs\/wp-json\/wp\/v2\/doc_tag?post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}