-- -- ec_order_cost/1 -- create or replace function ec_order_cost( integer ) returns numeric as $$ DECLARE v_order_id alias for $1; v_price numeric; v_shipping numeric; v_tax numeric; v_certificate numeric; BEGIN v_price := ec_total_price(v_order_id); v_shipping := ec_total_shipping(v_order_id); v_tax := ec_total_tax(v_order_id); v_certificate := ec_order_gift_cert_amount(v_order_id); return v_price + v_shipping + v_tax - v_certificate; END;$$ language plpgsql;