This repository was archived by the owner on Jun 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsynpay.module
More file actions
52 lines (47 loc) · 1.89 KB
/
synpay.module
File metadata and controls
52 lines (47 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
/**
* Заполняем адрес в профайле, нужно для комерца.
*/
function synapse_commerce_payment_entity_presave(EntityInterface $entity) {
if ($entity->bundle() == 'customer') {
$array = $entity->toArray();
if (!(isset($array['address']) && count($array['address']))) {
$fio = isset($entity->field_customer_fie->value) ? $entity->field_customer_fie->value : '';
$city = isset($entity->field_city->value) ? $entity->field_city->value : '';
$house = isset($entity->field_house->value) ? $entity->field_house->value : '';
$room = isset($entity->field_apartment->value) ? $entity->field_apartment->value : '';
$address = $city . $house . $room;
$entity->address->address_line1 = $address != '' ? $address : $fio;
$entity->address->country_code = 'RU';
/* дополнительные поля
$entity->address->administrative_area = 'Vologodskaya oblast';
$entity->address->locality = 'test';
$entity->address->dependent_locality = NULL;
$entity->address->postal_code = '160000';
$entity->address->sorting_code = NULL;
$entity->address->address_line2 = '';
$entity->address->organization = '';
$entity->address->given_name = 'Synapse';
$entity->address->additional_name = NULL;
$entity->address->family_name = 'Synapse';
*/
}
}
}
/**
* Меняем кнопку.
*/
function synapse_commerce_payment_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if ($form_id == 'commerce_checkout_flow_multistep_default') {
if (isset($form['actions']['next'])) {
$form['actions']['next'] = [
'#type' => 'submit',
'#value' => 'Оформить заказ',
'#button_type' => 'primary',
'#submit' => ['::submitForm'],
];
}
}
}