以下は、チェックアウト時に送料を取得する関数です。ただし、いくつかのこと/get関数に基づいて送料を返しています。カートの値が >=£100 ('p.price') の場合、'£0.00' の値を返す必要があります。それ以外の場合は、関数を通常どおり使用し$query->row('total')
ます。
function get_cart_total($cartID) {
$this->db->select('SUM((COALESCE(NULLIF(sc.override_price_from_auction, 0), p.price))*sc.quantity) AS total',FALSE);
$this->db->join('products AS p', 'sc.product_id = p.product_id');
$this->db->where('sc.cart_id',$cartID);
$query = $this->db->get('shopping_cart AS sc');
return $query->row('total');
function total_with_VAT($cartID, $taxAmount) {
$total = $this->get_cart_total($cartID);
$tax_inclusive_total = $total;
return $tax_inclusive_total;
}
function carriage_cost($cartID) {
$this->db->select('SUM(p.carriage*sc.quantity) AS total',FALSE);
$this->db->join('products AS p', 'sc.product_id = p.product_id');
$this->db->where('sc.cart_id',$cartID);
$query = $this->db->get('shopping_cart AS sc');
$query->row('total');
//echo $this->db->last_query();
return $query->row('total');
}