以下是在结帐时获取运输费用的功能。但是,它会根据一些事情/获取功能返回运输成本;如果购物车的价值 >=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');
}