Esempio n. 1
0
 public function reorder($where = '')
 {
     $k = $this->_tbl_key;
     $query = new CitruscartQuery();
     $query->select($this->_tbl_key);
     $query->select('ordering');
     $query->from($this->_tbl);
     $query->order('ordering ASC');
     $query->order('country_name ASC');
     $this->_db->setQuery((string) $query);
     if (!($orders = $this->_db->loadObjectList())) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // correct all the ordering numbers
     for ($i = 0, $n = count($orders); $i < $n; $i++) {
         if ($orders[$i]->ordering >= 0) {
             if ($orders[$i]->ordering != $i + 1) {
                 $orders[$i]->ordering = $i + 1;
                 $query = new CitruscartQuery();
                 $query->update($this->_tbl);
                 $query->set('ordering = ' . (int) $orders[$i]->ordering);
                 $query->where($k . ' = ' . $this->_db->Quote($orders[$i]->{$k}));
                 $this->_db->setQuery((string) $query);
                 $this->_db->query();
             }
         }
     }
     return true;
 }
Esempio n. 2
0
 /**
  * First stores the record
  * Then checks if it should be the default
  *
  * @see Citruscart/admin/tables/CitruscartTable#store($updateNulls)
  */
 function store($updateNulls = false)
 {
     if ($return = parent::store($updateNulls)) {
         if ($this->is_default_shipping == '1' || $this->is_default_billing == '1') {
             // update the defaults
             $query = new CitruscartQuery();
             $query->update("#__citruscart_addresses");
             $query->where("`user_id` = '{$this->user_id}'");
             $query->where("`address_id` != '{$this->address_id}'");
             if ($this->is_default_shipping == '1') {
                 $query->set("`is_default_shipping` = '0'");
             }
             if ($this->is_default_billing == '1') {
                 $query->set("`is_default_billing` = '0'");
             }
             $this->_db->setQuery((string) $query);
             if (!$this->_db->query()) {
                 $this->setError($this->_db->getErrorMsg());
                 return false;
             }
         }
     }
     return $return;
 }
Esempio n. 3
0
 /**
  *
  * @param unknown_type $user_id
  * @param unknown_type $session_id
  * @return unknown_type
  */
 function updateUserCartItemsSessionId($user_id, $session_id)
 {
     $db = JFactory::getDBO();
     Citruscart::load('CitruscartQuery', 'library.query');
     $query = new CitruscartQuery();
     $query->update("#__citruscart_carts");
     $query->set("`session_id` = '{$session_id}' ");
     $query->where("`user_id` = '{$user_id}'");
     $db->setQuery((string) $query);
     if (!$db->query()) {
         $this->setError($db->getErrorMsg());
         return false;
     }
     return true;
 }
Esempio n. 4
0
 public function clearSessionIds()
 {
     $query = new CitruscartQuery();
     $query->update('#__citruscart_wishlistitems');
     $query->set("session_id = ''");
     $query->where("user_id > 0");
     $db = $this->getDBO();
     $db->setQuery((string) $query);
     if (!$db->query()) {
         return false;
     }
     return true;
 }