Hi Patrik
Thanks for the information.
I’ve tried to create a shortcode to do what I’m after using your function wpinv_insert_invoice().
Bizarrely it seems to get stuck in a loop and create 1000s of invoices before the webbrowser comes back with an error.
Here’s my code, I’ve literally just grabbed it from your examples and modified it to be a shortcode. Probably done something basic wrong.
function create_blogging_invoice( $atts ) {
$atts = shortcode_atts( array(
'item_id' => null,
'user_id' => null
), $atts );
$item_id = $atts['item_id'];
$user_id = $atts['user_id'];
$data = array(
'status' => 'wpi-pending',
'user_id' => $user_id,
'cart_details' => array(
array(
'id' => $item_id
),
)
);
$invoice = wpinv_insert_invoice( $data, false );
return $invoice;
}
add_shortcode( 'create_blogging_invoice', 'create_blogging_invoice' );
Then I’m calling the above shortcode on a certain page load.
Any idea why the above would create 1000s of invoices?