本文整理汇总了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();
//}
}
}
}