Code:
/ class methods
function quote($method = '') {
global $order, $total_count;
// i ignore free shipping items.. all items are priced not matter what.
//$total_count = $total_count - $_SESSION['cart']->free_shipping_items();
// each array item is another array consisting of the product name, it's base shipping cost,
// the price of each extra unit shipped, and the IDs of each product in that price category.
$product_chart = array(
'smallmatted' => array(
'base' => 6,
'extra' => 1,
'ids' => array(1106, 1108, 1110, 1131, 1133, 1127, 1129)
),
'largematted' => array(
'base' => 7,
'extra' => 1,
'ids' => array(1107, 1109, 1111, 1128, 1132, 1134, 1130)
),
'canvasrolled' => array(
'base' => 8,
'extra' => 1,
'ids' => array(1135, 1137, 1140, 1142, 1143, 1146, 1148, 1150, 1152)
),
'smallframed' => array(
'base' => 24,
'extra' => 4,
'ids' => array(191, 192, 193, 194, 195, 196, 197, 198, 188, 189, 190, 1151, 1147)
),
'mediumframed' => array(
'base' => 45,
'extra' => 5,
'ids' => array(1136, 1141, 1147)
),
'largeframed' => array(
'base' => 75,
'extra' => 10,
'ids' => array(1138, 1139, 1144, 1145, 1149)
);
$cost = 0;
// calculate the cost based on quantity
foreach ($order->products as $product) {
$product_id = explode(':', $product['id']);
$product_id = $product_id[0];
foreach ($product_chart as $product_type => $product_details) {
if (in_array($product['id'], $product_details['ids'])) {
$qty = $product['qty'];
$cost += $product_details['base'] + $product_details['extra'] * ($qty - 1);
}
}
}
$this->quotes = array(
'id' => $this->code,
'module' => 'Shipping',
'methods' => array(
array(
'id' => $this->code,
'title' => MODULE_SHIPPING_MINE_TEXT_WAY,
'cost' => $cost
)
)
);
This accommodates a lot of my needs, but does not offer the ability to have different prices according to the final destination.
Bookmarks