Open PaulW187 opened 1 week ago
Hi @PaulW187, could you please provide some more details about the following?
Thank you!
Hi @Konamiman,
_woocommerce_invoices
Also this is how i access this meta field
if (OrderUtil::custom_orders_table_usage_is_enabled()) {
// HPOS usage is enabled.
$order = wc_get_order($order_id);
if ($order !== false) {
$invoices = $order->get_meta("_woocommerce_invoices", true);
}
} else {
// Traditional CPT-based orders are in use.
$invoices = get_post_meta( $order_id, '_woocommerce_invoices', true );
}
just like the documentation tells me to.
Thanks in advance
I am currently working on a project for a customer, which creates custom invoices and saves those in the order meta field, to the corresponding order. This plugin is already in use an was in use before switching to HPOS.
So lets start of with how this data i stored in the DB:
a:2:{i:0;a:5:{s:13:"document_type";s:13:"delivery_note";s:9:"timestamp";i:1730094654;s:14:"invoice_number";s:0:"";s:10:"invoice_id";s:32:"56bcadb1e4ca03118a90cce653b44393";s:7:"pdf_url";s:85:"https://mydomain/delivery_notes/56bcadb1e4ca03118a90cce653b44393.pdf";}i:1;a:5:{s:13:"document_type";s:7:"invoice";s:9:"timestamp";i:1730095277;s:14:"invoice_number";s:8:"24057440";s:10:"invoice_id";s:32:"075eaa1c3af89cc28c99c67fe6f59d6a";s:7:"pdf_url";s:79:"https://mydomain/invoices/075eaa1c3af89cc28c99c67fe6f59d6a.pdf";}}
I have altered the pdf_url for security reasons by i can ensure u that this is a valid DC2Type array. This is the data before switching to HPOS, which includes the delivery_note and the invoice. Upon switching to HPOS this field gets altered and will look like this.
a:1:{i:0;a:5:{s:13:"document_type";s:13:"delivery_note";s:9:"timestamp";i:1730094654;s:14:"invoice_number";s:0:"";s:10:"invoice_id";s:32:"56bcadb1e4ca03118a90cce653b44393";s:7:"pdf_url";s:85:"https://mydomain/delivery_notes/56bcadb1e4ca03118a90cce653b44393.pdf";}}
Again i have altered the domain for security reasons, but the array is still valid. But as you can see the invoice is missing. This was quite bizzare to me, so i thought it had to be our custom plugin that alters this array. Turns out the plugin is not the reason for the change, because if i completly disable this plugin, the field still gets changed.
Now i am wondering if this is a bug or if i have overseen some necassary information. I have already contacted the support, but the AI genearted response was not very helpfull.