I’m using wpinv_insert_invoice() to create my invoices. There are 5 different items, but each needs to be priced differently.
So for example, let’s say I have 3 types of apples:
Granny Smith
Red Delicious
Golden
Each time I invoice for my apples, I have different prices for them based on several factors. So let’s say I have three batches of Granny Smith apples.
Batch 1 costs 7.50
Batch 2 costs 10.50
Batch 3 costs 5.50
Now they are all the same item with the same item ID, but each has a custom price.
My cart details array might look like this:
array(
array("id" => 24, "custom_price" => 7.50),
array("id" => 24, "custom_price" => 10.50),
array("id" => 24, "custom_price" => 5.50)
);
Your ‘cart_items’ doesn’t work like this, since it just increments the quantity and takes the last custom price used so I end up with an invoice with one item.
Granny Smith apples, quantity 3, price 5.50
This won’t work for me, so what should I do?
I’ve considered:
Creating a brand new item, adding it to the invoice and then deleting the item, but I don’t think that will work since the invoice is based on the item code.
What I don’t want is to create thousands of unique items with different custom prices.
What can I do? This ground my development to a halt.