When setting a quantity in the wishlist to 0 and using 'Update Quantity', site errors.

Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in array_flip() (line 388 of /var/www/html/includes/entity.inc)

EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityDrupalWrapper->set() (line 737 of /var/www/html/sites/all/modules/entity/includes/entity.wrapper.inc).

Seems like the quantity function just needs to check if the new quantity is 0, and remove it instead of updating quantity.

Comments

chadsten created an issue. See original summary.

chadsten’s picture

$form_state['order']->order_id doesn't seem to exist in commerce_wishlist_handler_field_edit_quantity.inc during the delete lines foreach. Will continue to investigate.

chadsten’s picture

StatusFileSize
new1.2 KB

Created patch to resolve this issue.

The first change is pretty obvious - I just had to find the order ID.

The second change was due to the fact the old method of removing a line item was deleting all line items (for some reason) and deleting the wishlist. The function I replaced it with is the same used for the 'Remove' button, which seems to work correctly.

chadsten’s picture

StatusFileSize
new1.06 KB

Patch had gitignore changes. Removed.

chadsten’s picture

Status: Active » Needs review
neograph734’s picture

Status: Needs review » Needs work

I am not really sure why the order is loaded here as the variable is not used. I suppose only commerce_line_item_delete($line_item_id);
should be enough.

neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new805 bytes

Attached proposed resolution.

  • Neograph734 committed dc65775 on 7.x-3.x
    Issue #2569827 by chadsten, Neograph734: Update Quantities to 0 Causes
    
neograph734’s picture

Removing unused code not really needs a review... (and my patch was wrong). Committed the change from #6. Thanks for finding this error!

neograph734’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.