I'm using the below code to mark products as shippable or not based on the value of the item's weight field. My reason for doing this is outlined here: http://www.ubercart.org/forum/support/18791/free_shipping_specific_produ...
The code works as expected. I commented some code out because I am deciding which is more efficient. Normally I just select the Remove checkbox associated with the item, then click Update cart. When I do that with this module enabled, it reloads the page as normal with the "Your cart has been updated" notification and NO errors. Unfortunately, it does NOT remove the item from the cart. There's no way to remove the item without disabling this code first.
My problem is that when using this code I am unable to remove the item that matches the if test from the cart.
Example: If I use the code that is not comment out ($item->weight !== 1) I am not able to remove any items that do not have weight = 1. If I use the commented code, I cannot remove any items.
What's wrong with my code that's causing this? I followed this information as much as possible: http://www.ubercart.org/docs/api/hook_cart_item
<?php
/**
* This module checks the item's weight and if '1' it marks the item as shippable. If '0' marks as non-shippable.
*/
function uc_nonshippable_cart_item($op, &$item) {
switch ($op) {
case 'load':
if($item->weight !== 1) {
$item->data['shippable'] = '0';
}
/*if($item->weight == 1) {
$item->data['shippable'] = '1';
} else {
$item->data['shippable'] = '0';
}*/
break;
}
}
?>
