Hi,
I am developping a module where you can choose that an attribute is multiplied by the quantity or not. I need this because I want to sell ski-holidays. If a family wants insurrance, the attribte price needs to be multiplied by the quantity (= number of persons). If a family selects a reduction for children (1, 2 or 3 children), they only get this reduction once and should not be multiplied by the quantity.
To do this I used the hook cart_item but the problem is that the original attribute module is called after my own created atrribute module (uc_aattrb). SO the changes I've made are overwritten again. I tried to change the weight in the system table, but without success.
/**
* Implementation of hook_cart_item().
*/
function uc_aattrb_cart_item($op, &$item) {
switch ($op) {
case 'load':
$item->options = _uc_aattrb_cart_product_get_options($item);
$op_costs = 0;
$op_prices = 0;
$op_weight = 0;
foreach ($item->options as $option){
if ($option['multiply_qty']=="yes"){
$op_costs += $option['cost'];
$op_prices1 += $option['price'];
$op_cost1 += $option['cost'];
$op_weight += $option['weight'];
}else{
$op_prices2 += $option['price'];
$op_cost2 += $option['cost'];
}
}
$item->cost += $op_costs;
$item->weight += $op_weight;
$op_costs += $option['cost'];
$item->cost_multiply += $op_costs1;
$item->cost_nomultiply += $op_costs2;
$item->price_attributes_multiply += $op_prices1;
$item->price_attributes_nomultiply += $op_prices2;
$item->price_product += $item->price;
if (!empty($item->data['model'])) {
$item->model = $item->data['model'];
}
//echo '<pre>'. print_r($item, TRUE) .'</pre>';
//echo "uc_aattrb_cart_item:". $item->price;
//echo '<pre>'. print_r($item, TRUE) .'</pre>';
//echo '<pre>3==>'. print_r($item, TRUE) .'</pre>';
break;
}
}