I am trying to get the invoice number of a WooCommerce order by using a regular expression.
The invoice number is returned in the meta_data from the Woocommerce Order Updated piece.
The part of the meta data that contains the invoice number would look like this:
{
"id": 45338,
"key": "_wcpdf_invoice_date_formatted",
"value": "2024-09-10 21:44:15"
},
{
"id": 45339,
"key": "_wcpdf_invoice_number",
"value": "13100"
},
{
"id": 45340,
"key": "_wcpdf_invoice_number_data",
"value": {
"number": 13100,
"formatted_number": "13100",
"prefix": "",
"suffix": "",
"document_type": "invoice",
"order_id": 1600,
"padding": ""
}
},
I’m using the following regular expression to get the invoice number:
/"key":\s*"_wcpdf_invoice_number",\s*"value":\s*"(\d+)"/
The regex is working perfectly when I test it on regex101.com, but for some reason I can’t manage to get it to work in the Text Helper.
Any ideas to what I am doing wrong?