0

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.

Prophet
  • 32,350
  • 22
  • 54
  • 79
Shino
  • 125
  • 2
  • 5
  • 14

1 Answers1

2

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);

Keith Palmer Jr.
  • 27,666
  • 16
  • 68
  • 105
  • I used this code for update. But I am getting Fatal error & the error is "Fatal error: Call to undefined method QuickBooks_IPP_Service_Item::update()". Please help. – Shino Jun 09 '14 at 06:09
  • Make sure you have the latest code from GitHub. You're not using the latest code. – Keith Palmer Jr. Jun 09 '14 at 11:03
  • @KeithPalmerJr, where can I find the list of QB API actions such as `->setDisplayName()` on vendors? Their documentation sucks. I'm looking to update vendor address information, is it all keyed like `->set[ObjectPropertyName]`? – Eric L. Jan 13 '16 at 18:45
  • 1
    The method names literally map exactly to the property names in Intuit's docs -- so ->setGivenName($v) ->getGivenName(); ->setDisplayName($v); ->getDisplayName(); etc. etc. etc. – Keith Palmer Jr. Jan 13 '16 at 19:36