;; Cart cart-mini fragment handler
;; returns: sx
;;
;; Renders the cart icon with badge (or logo when empty).

(defhandler cart-mini (&key user_id session_id oob)
  (let ((summary (service "cart" "cart-summary"
                   :user-id (when user_id (parse-int user_id))
                   :session-id session_id))
        (count (+ (or (get summary "count") 0)
                  (or (get summary "calendar_count") 0)
                  (or (get summary "ticket_count") 0))))
    (~shared:fragments/cart-mini
      :cart-count count
      :blog-url (app-url "blog" "")
      :cart-url (app-url "cart" "")
      :oob (when oob oob))))
