I create my own Shipping Method, which is dependent on the categories. The calculation of the costs works great. When I go through the checkout process, the shipping costs are shown correctly on the checkout/shipping page, but when i go further to the confirmation page, the costs for shipping are displayed as '0'.
I am not sure where to start. Obviously, on the checkout/shipping the getQuote method is used to determine the shipping costs. But on the confirmation page not.
This is my code:
Code: Select all
<?php
class ModelShippingCategorybased extends Model {
function getQuote($address) {
$this->load->language('shipping/category_based');
$products = $this->cart->getProducts();
$this->load->model('catalog/product');
$this->load->model('catalog/category');
$highest = 0;
foreach($products as $product){
$cats = $this->model_catalog_product->getCategories($product['product_id']);
$categories = array();
foreach($cats as $cat){
$realcat = $this->model_catalog_category->getCategory($cat['category_id']);
$categories[] = $realcat;
while($realcat['parent_id']!=0){
$realcat = $this->model_catalog_category->getCategory($realcat['parent_id']);
$categories[] = $realcat;
}
}
foreach($categories as $cat){
$category = $this->model_catalog_category->getCategory($cat['category_id']);
$costs = $category['shipping_cost'];
if($costs > $highest){
$highest = $costs;
}
}
}
$status = TRUE;
$method_data = array();
if ($status) {
$quote_data = array();
$quote_data['category_based'] = array(
'id' => 'category_based.category_based',
'title' => $this->language->get('text_description'),
'cost' => $this->currency->format($highest),
'tax_class_id' => 0,
'text' => $this->currency->format($highest)
);
$method_data = array(
'id' => 'category_based',
'title' => $this->language->get('text_title'),
'quote' => $quote_data,
'sort_order' => $this->config->get('category_based_sort_order'),
'error' => FALSE
);
}
return $method_data;
}
}
?>