当前位置: 首页>>代码示例>>PHP>>正文


PHP Warehouse::removeCarrier方法代码示例

本文整理汇总了PHP中Warehouse::removeCarrier方法的典型用法代码示例。如果您正苦于以下问题:PHP Warehouse::removeCarrier方法的具体用法?PHP Warehouse::removeCarrier怎么用?PHP Warehouse::removeCarrier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Warehouse的用法示例。


在下文中一共展示了Warehouse::removeCarrier方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postProcess

 public function postProcess()
 {
     if (Tools::getValue('submitAdd' . $this->table)) {
         /* Checking fields validity */
         $this->validateRules();
         if (!count($this->errors)) {
             $id = (int) Tools::getValue('id_' . $this->table);
             /* Object update */
             if (isset($id) && !empty($id)) {
                 try {
                     if ($this->tabAccess['edit'] === '1') {
                         $current_carrier = new Carrier($id);
                         if (!Validate::isLoadedObject($current_carrier)) {
                             throw new PrestaShopException('Cannot load Carrier object');
                         }
                         // Duplicate current Carrier
                         $new_carrier = $current_carrier->duplicateObject();
                         if (Validate::isLoadedObject($new_carrier)) {
                             // Set flag deteled to true for historization
                             $current_carrier->deleted = true;
                             $current_carrier->update();
                             // Fill the new carrier object
                             $this->copyFromPost($new_carrier, $this->table);
                             $new_carrier->position = $current_carrier->position;
                             $new_carrier->update();
                             $this->updateAssoShop($new_carrier->id);
                             $new_carrier->copyCarrierData((int) $current_carrier->id);
                             $this->changeGroups($new_carrier->id);
                             // Call of hooks
                             Hook::exec('actionCarrierUpdate', array('id_carrier' => (int) $current_carrier->id, 'carrier' => $new_carrier));
                             $this->postImage($new_carrier->id);
                             $this->changeZones($new_carrier->id);
                             $new_carrier->setTaxRulesGroup((int) Tools::getValue('id_tax_rules_group'));
                             Tools::redirectAdmin(self::$currentIndex . '&id_' . $this->table . '=' . $current_carrier->id . '&conf=4&token=' . $this->token);
                         } else {
                             $this->errors[] = Tools::displayError('An error occurred while updating an object.') . ' <b>' . $this->table . '</b>';
                         }
                     } else {
                         $this->errors[] = Tools::displayError('You do not have permission to edit this.');
                     }
                 } catch (PrestaShopException $e) {
                     $this->errors[] = $e->getMessage();
                 }
             } else {
                 if ($this->tabAccess['add'] === '1') {
                     // Create new Carrier
                     $carrier = new Carrier();
                     $this->copyFromPost($carrier, $this->table);
                     $carrier->position = Carrier::getHigherPosition() + 1;
                     if ($carrier->add()) {
                         if (($_POST['id_' . $this->table] = $carrier->id) && $this->postImage($carrier->id) && $this->_redirect) {
                             $carrier->setTaxRulesGroup((int) Tools::getValue('id_tax_rules_group'), true);
                             $this->changeZones($carrier->id);
                             $this->changeGroups($carrier->id);
                             $this->updateAssoShop($carrier->id);
                             Tools::redirectAdmin(self::$currentIndex . '&id_' . $this->table . '=' . $carrier->id . '&conf=3&token=' . $this->token);
                         }
                     } else {
                         $this->errors[] = Tools::displayError('An error occurred while creating an object.') . ' <b>' . $this->table . '</b>';
                     }
                 } else {
                     $this->errors[] = Tools::displayError('You do not have permission to add this.');
                 }
             }
         }
         parent::postProcess();
     } else {
         if (isset($_GET['isFree' . $this->table])) {
             $this->processIsFree();
         } else {
             /*
             	if ((Tools::isSubmit('submitDel'.$this->table) && in_array(Configuration::get('PS_CARRIER_DEFAULT'), Tools::getValue('carrierBox')))
             				|| (isset($_GET['delete'.$this->table]) && Tools::getValue('id_carrier') == Configuration::get('PS_CARRIER_DEFAULT')))
             					$this->errors[] = $this->l('Please set another carrier as default before deleting this one.');
             			else
             			{
             */
             // if deletion : removes the carrier from the warehouse/carrier association
             if (Tools::isSubmit('delete' . $this->table)) {
                 $id = (int) Tools::getValue('id_' . $this->table);
                 // Delete from the reference_id and not from the carrier id
                 $carrier = new Carrier((int) $id);
                 Warehouse::removeCarrier($carrier->id_reference);
             } else {
                 if (Tools::isSubmit($this->table . 'Box') && count(Tools::isSubmit($this->table . 'Box')) > 0) {
                     $ids = Tools::getValue($this->table . 'Box');
                     array_walk($ids, 'intval');
                     foreach ($ids as $id) {
                         // Delete from the reference_id and not from the carrier id
                         $carrier = new Carrier((int) $id);
                         Warehouse::removeCarrier($carrier->id_reference);
                     }
                 }
             }
             parent::postProcess();
             Carrier::cleanPositions();
             //}
         }
     }
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:100,代码来源:AdminCarriersController.php


注:本文中的Warehouse::removeCarrier方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。