2013-10-08 1 views
-2

다음은 결제 시점에서 운송비를받는 기능입니다. 그것은 몇 가지를 기반으로 운송 비용을 반환/기능을 얻을 수 있지만, 카트의 값이있는 경우> = £ 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'); 
    } 
+0

문 – Ibu

+2

방금 ​​$ 질의 - 경우> 행 ('총')가 100보다 크거나 sc.quantity (100)보다 큰 경우 의미합니까 경우에 던져 좋은 장소? –

+0

어떻게 알 수 있습니까? 테이블 구조? '$ this'의 객체 속성? 아무데도 충분한 정보가 없습니다 – SmokeyPHP

답변

1

하는 경우 나는 정확하게 당신을 이해합니다, 당신은 단지 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'); 

    $total = $query->row()->total; 
    return $total >= 100 ? 0 : $total; 
} 
관련 문제