This is a demo page showing some of my work.
Feel free to download the Files on this page and let me know what you think!
/** * @file * Rental custom price calculations. * * Client has special discount on complete weeks. * */ /** * Implementation of hook_cart_item(). */ function uc_date_qty_cart_item($op, &$item) { if ($op == 'load') { // Load up the corresponding node so we can get the computed field data from it if (isset($item->data['node_checkout_nid']) && $node = node_load($item->data['node_checkout_nid'])) { $item->checkout_node = $node; } //Get Rental Days amount from Reservation nodes if ( isset($node->field_rentdays) ) { $dayqty = abs($node->field_rentdays[0]['value']); } $nodepr = node_load($item->nid); $weekprice = $nodepr->list_price; //Set Price of Quick Reservation Product to Car Price if ( isset($node->field_quickcar) ) { $refnode = node_load($node->field_quickcar[0][nid]); //echo '<pre>'; print_r($refnode); echo '<pre>'; $quickcarprice = $refnode->sell_price; $item->price = $quickcarprice; $quickdays = abs($node->field_datedays[0]['value']); $dayqty = $quickdays; $weekprice = $refnode->list_price; } //Get Weeks and Remaining days amount //And set price to calculated amount //Keeping calculations simple to easily edit or change if/when needed by client /*if ($dayqty > 1){ $item->qty = $dayqty; } $item->qty = $dayqty;*/ $oneweek = 7; $weeks = abs(floor($dayqty / $oneweek)); $remainingdays = $dayqty - ($weeks*7); //$weekprice = $item->price*6; if ($weeks > 0){ $item->price = ($weekprice*$weeks + $remainingdays*$item->price); }else{ $item->price = $item->price*$dayqty; } } }