I am using the open-source QuickBooks
PHP
DevKit on GitHub
.
I added an Item using the example example_items_add.php
.
How can I update & delete an item?
Please help me.
Updating Items:
Updating items is very similar to adding them - just call ->update(...)
instead of calling ->add(...)
.
You can see an example here:
The code looks like:
// Get the existing item
$items = $ItemService->query($Context, $realm, "SELECT * FROM Item WHERE Id = '2' ");
$Item = $items[0];
// Update the name of the item
$Item->setName($Item->getName() . ' ' . mt_rand(0, 1000));
if ($resp = $ItemService->update($Context, $realm, $Item->getId(), $Item))
{
print('Updated the item name to ' . $Item->getName());
}
Deleting Items:
Per Intuit's documentation, items don't really support true deletes.
Instead, you mark them as "inactive" so that they no longer show up in the UI. This is as simple as making an item update, and setting the Active
flag to false
.
$Item->setActive(false);