hook_cart_item($op, &$item)
ubercart/docs/hooks.php, line 175
Add extra data about an item in the cart.
Products that are added to a customer's cart are referred as items until the sale is completed. Just think of a grocery store having a bunch of products on the shelves but putting a sign over the express lane saying "15 Items or Less." hook_cart_item() is in charge of acting on items at various times like when they are being added to a cart, saved, loaded, and checked out.
Here's the rationale for this hook: Products may change on a live site during a price increase or change to attribute adjustments. If a user has previously added an item to their cart, when they go to checkout or view their cart screen we want the latest pricing and model numbers to show. So, the essential product information is stored in the cart, but when the items in a cart are loaded, modules are given a chance to adjust the data against the latest settings.
$op The action that is occurring. Possible values:
No return value for load. TRUE or FALSE for can_ship.
| Name | Description |
|---|---|
| Hooks | Allow modules to interact with the Drupal core. |
<?php
function hook_cart_item($op, &$item) {
switch ($op) {
case 'load':
$term = array_shift(taxonomy_node_get_terms_by_vocabulary($item->nid, variable_get('uc_manufacturer_vid', 0)));
$arg1->manufacturer = $term->name;
break;
}
}
?>