At the moment I add shipping charge 65Kr.
There are only four prices in the shop.
I need to change the shipping charge to the following way.
Product which cost 198Kr and 268Kr needs 25Kr and more than that price (418 and 498Kr) needs 65Kr.
If a customer buys 198Kr and 418kr, then she needs to pay 65Kr. This means if there is one item which needs 65Kr , then shipping will be 65Kr.
If a customer buys 198Kr and 268Kr, then she needs to pay 25Kr.
I am not sure how to add this shipping to the total cost.
I use the following code to update the total price.
And I add 65Kr at the checkout.
function updateCart($productid,$fullproduct){
$cart = isset($_SESSION['cart']) ? $_SESSION['cart'] : array();
$productid = id_clean($productid);
$totalprice = 0;
if (count($fullproduct)){
if (isset($cart[$productid])){
$prevct = $cart[$productid]['count'];
$prevname = $cart[$productid]['name'];
$prevprice = $cart[$productid]['price'];
$cart[$productid] = array(
'name' => $prevname,
'price' => $prevprice,
'count' => $prevct + 1
);
}else{
$cart[$productid] = array(
'name' => $fullproduct['name'],
'price' => $fullproduct['price'],
'count' => 1
);
}
foreach ($cart as $id => $product){
$totalprice += $product['price'] * $product['count'];
}
$_SESSION['totalprice'] = $totalprice;
$_SESSION['cart'] = $cart;
$msg = $this->lang->line('orders_added_cart');
$this->session->set_flashdata('conf_msg', $msg);
}
}
at the checkout
...
$shipping= 65;
$grandtotal = (int)$totalprice + $shipping;
...
As you can see I can use session to keep track of size or price. So I think I can use them to find the final shipping price.
I will appreciate any helping hands.
Thanks in advance.