Skip to content

Instantly share code, notes, and snippets.

@Fi1osof
Created January 22, 2014 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fi1osof/0f1d77f8c7e4070243ce to your computer and use it in GitHub Desktop.
Save Fi1osof/0f1d77f8c7e4070243ce to your computer and use it in GitHub Desktop.
<?php
/*
Оформление заказа
*/
require_once MODX_CORE_PATH . 'components/basket/processors/basket/web/orders/submit.class.php';
class modWebShopBucketZakazProcessor extends modBasketWebOrdersSubmitProcessor{
protected $allowGetUserByEmail = true;
protected function getFields(){
$fields = (array)parent::getFields();
switch($this->getProperty('ordertype')){
case 'Moscow':
$this->setProperty('city', 'Москва');
$fields['delivery'] = array(
'name' => 'Форма доставки или приобретения',
'error_message' => 'Укажите форму доставки или приобретения',
'required' => true,
);
$fields['mobilephone'] = array(
'name' => 'Сотовый телефон',
'error_message' => 'Укажите телефон',
'required' => true,
);
if($this->getProperty('delivery') != 'Самовывоз'){
$fields['metro'] = array(
'name' => 'Ближайшая станция метро',
'error_message' => 'Укажите ближайшую станцию метро',
'required' => true,
);
}
break;
case 'Russia':
$fields['payment'] = array(
'name' => 'Форма оплаты',
'error_message' => 'Укажите форму оплаты',
'required' => true,
);
$fields['zip'] = array(
'name' => 'Индекс',
'error_message' => 'Укажите индекс',
'required' => true,
);
$fields['region'] = array(
'name' => 'Республика, край, область, район',
'error_message' => 'Укажите область',
'required' => true,
);
$fields['city'] = array(
'name' => 'Город',
'error_message' => 'Укажите населенный пункт',
'required' => true,
);
$fields['appartment'] = array(
'name' => 'Улица, дом, корп., кв.',
'error_message' => 'Укажите адрес',
'required' => true,
);
break;
default:;
}
return $fields;
}
public function beforeSet(){
$address = array();
// Устанавливаем данные адреса
switch($this->getProperty('ordertype')){
case 'Moscow':
if($metro = $this->getProperty('metro')){
$metro = "м. {$metro}";
$address[] = $metro;
// $this->setProperty('metro', $metro);
}
if($addr = $this->getProperty('address')){
$address[] = $addr;
}
break;
case 'Russia':
if($zip = $this->getProperty('zip')){
$address[] = $zip;
}
if($region = $this->getProperty('region')){
$address[] = $region;
}
if($city = $this->getProperty('city')){
$address[] = $city;
}
if($appartment = $this->getProperty('appartment')){
$address[] = $appartment;
}
if($abox = $this->getProperty('abox')){
$address[] = "а/я {$abox}";
}
default:;
}
if($address){
$this->setProperty('address', implode(", ", $address));
}
return parent::beforeSet();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment