Пример #1
0
 function delete($oid = null, $doReconciliation = true)
 {
     $k = $this->_tbl_key;
     if ($oid) {
         $this->{$k} = intval($oid);
     }
     $id = $this->{$k};
     if ($return = parent::delete($oid)) {
         if ($id) {
             $query = "UPDATE #__citruscart_wishlistitems SET wishlist_id = '0' WHERE wishlist_id = '" . $id . "'";
             $db = $this->getDBO();
             $db->setQuery($query);
             $db->query();
         }
     }
     return parent::check();
 }
Пример #2
0
 /**
  * 
  * @param $oid
  * @return unknown_type
  */
 function delete($oid = null, $doReconciliation = true)
 {
     $k = $this->_tbl_key;
     if ($oid) {
         $this->{$k} = intval($oid);
     }
     if ($doReconciliation) {
         if ($oid) {
             $row = JTable::getInstance('ProductComments', 'CitruscartTable');
             $row->load($oid);
             $product_id = $row->product_id;
         } else {
             $product_id = $this->product_id;
         }
     }
     if (parent::delete($oid)) {
         DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models');
         $model = DSCModel::getInstance('ProductCommentsHelpfulness', 'CitruscartModel');
         $model->setState('filter_comment', $this->{$k});
         if ($items = $model->getList()) {
             $table = $model->getTable();
             foreach ($items as $item) {
                 if (!$table->delete($item->productcommentshelpfulness_id)) {
                     $this->setError($table->getError());
                 }
             }
         }
         if ($doReconciliation) {
             $product = JTable::getInstance('Products', 'CitruscartTable');
             $product->load($product_id);
             $product->updateOverallRating();
             if (!$product->save()) {
                 $this->setError($product->getError());
             }
         }
     }
     return parent::check();
 }
Пример #3
0
 /**
  * Checks the entry to maintain DB integrity
  * @return unknown_type
  */
 function check()
 {
     $config = Citruscart::getInstance();
     if (!$this->addresstype_id) {
         $this->addresstype_id = '1';
     }
     $address_type = $this->addresstype_id;
     if (empty($this->user_id)) {
         $this->user_id = JFactory::getUser()->id;
         if (empty($this->user_id)) {
             $this->setError(JText::_('COM_CITRUSCART_USER_REQUIRED'));
         }
     }
     Citruscart::load('CitruscartHelperAddresses', 'helpers.addresses');
     $elements = CitruscartHelperAddresses::getAddressElementsData($address_type);
     if (empty($this->address_name)) {
         $this->address_name = $this->address_1;
     }
     if (empty($this->address_name) && $elements['address_name'][1]) {
         $this->setError(JText::_("COM_CITRUSCART_PLEASE_INCLUDE_AN_ADDRESS_TITLE" . $address_type));
     }
     $address_checks = array(array('first_name', 'name', "COM_CITRUSCART_FIRST_NAME_REQUIRED"), array('middle_name', 'middle', "COM_CITRUSCART_MIDDLE_NAME_REQUIRED"), array('last_name', 'last', "COM_CITRUSCART_LAST_NAME_REQUIRED"), array('address_1', 'address1', "COM_CITRUSCART_AT_LEAST_ONE_ADDRESS_LINE_IS_REQUIRED"), array('address_2', 'address2', "COM_CITRUSCART_SECOND_ADDRESS_LINE_IS_REQUIRED"), array('company', 'company', "COM_CITRUSCART_COMPANY_REQUIRED"), array('tax_number', 'tax_number', "COM_CITRUSCART_COMPANY_TAX_NUMBER_REQUIRED"), array('city', 'city', "COM_CITRUSCART_CITY_REQUIRED"), array('postal_code', 'zip', "COM_CITRUSCART_POSTAL_CODE_REQUIRED"), array('phone_1', 'phone', "COM_CITRUSCART_PHONE_REQUIRED"));
     for ($i = 0, $c = count($address_checks); $i < $c; $i++) {
         $current = $address_checks[$i];
         if (empty($this->{$current}[0]) && $elements[$current[1]][1]) {
             $this->setError(JText::_($current[2]));
         }
     }
     if (empty($this->country_id)) {
         if ($elements['country'][1]) {
             $this->setError(JText::_('COM_CITRUSCART_COUNTRY_REQUIRED'));
         } else {
             $this->country_id = 9999;
         }
     }
     $countryA = explode(',', trim($config->get('ignored_countries', '83,188,190')));
     if (empty($this->zone_id) && !in_array($this->country_id, $countryA)) {
         if (isset($elements['zone'][1])) {
             $this->setError(JText::_('COM_CITRUSCART_ZONE_REQUIRED'));
         } else {
             $this->zone_id = 9999;
         }
     }
     return parent::check();
 }
 /**
  * Run function when deleting
  * @see Citruscart/admin/tables/CitruscartTable#save()
  */
 function delete($oid = null, $doReconciliation = true)
 {
     $k = $this->_tbl_key;
     if ($oid) {
         $this->{$k} = intval($oid);
     }
     if ($doReconciliation) {
         $pa = JTable::getInstance('ProductAttributes', 'CitruscartTable');
         if ($oid) {
             $row = JTable::getInstance('ProductAttributeOptions', 'CitruscartTable');
             $row->load($oid);
             $pa->load($row->productattribute_id);
         } else {
             $pa->load($this->productattribute_id);
         }
         $product_id = $pa->product_id;
     }
     if ($return = parent::delete($oid)) {
         DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models');
         $model = DSCModel::getInstance('ProductAttributeOptionValues', 'CitruscartModel');
         $model->setState('filter_option', $this->{$k});
         if ($items = $model->getList()) {
             $table = $model->getTable();
             foreach ($items as $item) {
                 if (!$table->delete($item->productattributeoptionvalue_id)) {
                     $this->setError($table->getError());
                 }
             }
         }
         if ($doReconciliation) {
             Citruscart::load("CitruscartHelperProduct", 'helpers.product');
             CitruscartHelperProduct::doProductQuantitiesReconciliation($product_id);
         }
     }
     return parent::check();
 }
Пример #5
0
 function delete($oid = null)
 {
     $k = $this->_tbl_key;
     if ($oid) {
         $this->{$k} = intval($oid);
     }
     if ($return = parent::delete($oid)) {
         $query = new CitruscartQuery();
         $query->delete();
         $query->from('#__citruscart_productdownloads');
         $query->where('productfile_id = ' . $this->{$k});
         $this->_db->setQuery((string) $query);
         $this->_db->query();
         $query = new CitruscartQuery();
         $query->delete();
         $query->from('#__citruscart_productdownloadlogs');
         $query->where('productfile_id = ' . $this->{$k});
         $this->_db->setQuery((string) $query);
         $this->_db->query();
     }
     return parent::check();
 }
Пример #6
0
 public function delete($oid = null)
 {
     $delete = array();
     $k = $this->_tbl_key;
     if ($oid) {
         $this->{$k} = intval($oid);
     }
     // this should all be a transaction...
     // Delete all the orderitems, orderpayments, ordershipping, etc
     $delete['items'] = $this->deleteItems('items', $oid);
     $delete['payments'] = $this->deleteItems('payments', $oid);
     $delete['info'] = $this->deleteItems('info', $oid);
     $delete['shippings'] = $this->deleteItems('shippings', $oid);
     $delete['history'] = $this->deleteItems('history', $oid);
     $delete['taxclasses'] = $this->deleteItems('taxclasses', $oid);
     $delete['taxrates'] = $this->deleteItems('taxrates', $oid);
     $delete['coupons'] = $this->deleteItems('coupons', $oid);
     $delete['order'] = parent::delete($oid);
     $this->deleteResults = $delete;
     return parent::check();
 }