Skip to content

Commit

Permalink
fix: always add client emailaddress to consignment in BE (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
joerivanveen authored and EdieLemoine committed Dec 20, 2021
1 parent 4a28765 commit df9489d
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/Constant.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class Constant

public const EXCLUSIVE_FIELDS_NL = [
self::SENT_ORDER_STATE_FOR_DIGITAL_STAMPS_CONFIGURATION_NAME,
self::SHARE_CUSTOMER_EMAIL_CONFIGURATION_NAME,
];
public const CARRIER_EXCLUSIVE = [
'POSTNL' => [
Expand Down
4 changes: 4 additions & 0 deletions src/Factory/Consignment/ConsignmentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ private function setRecipient(): void
*/
private function getEmailConfiguration(): string
{
if ($this->module->isBE()) {
return $this->orderData['email'];
}

$emailConfiguration = Configuration::get(Constant::SHARE_CUSTOMER_EMAIL_CONFIGURATION_NAME);

return $emailConfiguration ? $this->orderData['email'] : '';
Expand Down
6 changes: 4 additions & 2 deletions src/Module/Configuration/AbstractForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@

abstract class AbstractForm
{
protected const FIELD_TYPE_SELECT = 'select';
protected const FIELD_TYPE_SWITCH = 'switch';
protected const FIELD_TYPE_SELECT = 'select';
protected const FIELD_TYPE_SWITCH = 'switch';
protected const FIELD_TYPE_TEXT = 'text';
protected const FIELD_TYPE_CHECKBOX = 'checkbox';

/** @var Module */
protected $module;
Expand Down
8 changes: 4 additions & 4 deletions src/Module/Configuration/CustomsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function getFields(): array
{
return [
Constant::CUSTOMS_FORM_CONFIGURATION_NAME => [
'type' => 'select',
'type' => self::FIELD_TYPE_SELECT,
'label' => $this->module->l('Default customs form', 'customsform'),
'name' => Constant::CUSTOMS_FORM_CONFIGURATION_NAME,
'options' => [
Expand All @@ -39,12 +39,12 @@ protected function getFields(): array
],
],
Constant::DEFAULT_CUSTOMS_CODE_CONFIGURATION_NAME => [
'type' => 'text',
'type' => self::FIELD_TYPE_TEXT,
'label' => $this->module->l('Default customs code', 'customsform'),
'name' => Constant::DEFAULT_CUSTOMS_CODE_CONFIGURATION_NAME,
],
Constant::DEFAULT_CUSTOMS_ORIGIN_CONFIGURATION_NAME => [
'type' => 'select',
'type' => self::FIELD_TYPE_SELECT,
'label' => $this->module->l('Default customs origin', 'customsform'),
'name' => Constant::DEFAULT_CUSTOMS_ORIGIN_CONFIGURATION_NAME,
'options' => [
Expand All @@ -55,7 +55,7 @@ protected function getFields(): array
'default_value' => $this->module->isBE() ? AbstractConsignment::CC_BE : AbstractConsignment::CC_NL,
],
Constant::CUSTOMS_AGE_CHECK_CONFIGURATION_NAME => [
'type' => 'switch',
'type' => self::FIELD_TYPE_SWITCH,
'label' => $this->module->l('Default customs age check', 'customsform'),
'name' => Constant::CUSTOMS_AGE_CHECK_CONFIGURATION_NAME,
'is_bool' => true,
Expand Down
5 changes: 4 additions & 1 deletion src/Module/Configuration/GeneralForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ protected function getFields(): array
{
return [
Constant::SHARE_CUSTOMER_EMAIL_CONFIGURATION_NAME => [
'type' => self::FIELD_TYPE_SWITCH,
'type' => $this->getExclusiveNlFieldType(
self::FIELD_TYPE_SWITCH,
Constant::SHARE_CUSTOMER_EMAIL_CONFIGURATION_NAME
),
'label' => $this->module->l('Share customer email with MyParcel', $this->getNamespace()),
'name' => Constant::SHARE_CUSTOMER_EMAIL_CONFIGURATION_NAME,
],
Expand Down
10 changes: 5 additions & 5 deletions src/Module/Configuration/LabelForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protected function getFields(): array
{
return [
Constant::LABEL_DESCRIPTION_CONFIGURATION_NAME => [
'type' => 'text',
'type' => self::FIELD_TYPE_TEXT,
'label' => $this->module->l('Label description', 'labelform'),
'name' => Constant::LABEL_DESCRIPTION_CONFIGURATION_NAME,
'placeholder' => '{order.id} {order.reference}',
Expand All @@ -36,7 +36,7 @@ protected function getFields(): array
],
],
Constant::LABEL_SIZE_CONFIGURATION_NAME => [
'type' => 'select',
'type' => self::FIELD_TYPE_SELECT,
'label' => $this->module->l('Default label size', 'labelform'),
'name' => Constant::LABEL_SIZE_CONFIGURATION_NAME,
'options' => [
Expand All @@ -49,7 +49,7 @@ protected function getFields(): array
],
],
Constant::LABEL_POSITION_CONFIGURATION_NAME => [
'type' => 'select',
'type' => self::FIELD_TYPE_SELECT,
'label' => $this->module->l('Default label position', 'labelform'),
'name' => Constant::LABEL_POSITION_CONFIGURATION_NAME,
'form_group_class' => 'label_position',
Expand All @@ -65,7 +65,7 @@ protected function getFields(): array
],
],
Constant::LABEL_OPEN_DOWNLOAD_CONFIGURATION_NAME => [
'type' => 'select',
'type' => self::FIELD_TYPE_SELECT,
'label' => $this->module->l('Open or download label', 'labelform'),
'name' => Constant::LABEL_OPEN_DOWNLOAD_CONFIGURATION_NAME,
'options' => [
Expand All @@ -78,7 +78,7 @@ protected function getFields(): array
],
],
Constant::LABEL_PROMPT_POSITION_CONFIGURATION_NAME => [
'type' => 'switch',
'type' => self::FIELD_TYPE_SWITCH,
'label' => $this->module->l('Prompt for label position', 'labelform'),
'name' => Constant::LABEL_PROMPT_POSITION_CONFIGURATION_NAME,
'required' => false,
Expand Down
14 changes: 7 additions & 7 deletions src/Module/Configuration/OrderForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function getFields(): array

return [
Constant::LABEL_CREATED_ORDER_STATUS_CONFIGURATION_NAME => [
'type' => 'select',
'type' => self::FIELD_TYPE_SELECT,
'label' => $this->module->l('Order status when label created', 'orderform'),
'name' => Constant::LABEL_CREATED_ORDER_STATUS_CONFIGURATION_NAME,
'options' => [
Expand All @@ -40,7 +40,7 @@ protected function getFields(): array
],
],
Constant::LABEL_SCANNED_ORDER_STATUS_CONFIGURATION_NAME => [
'type' => 'select',
'type' => self::FIELD_TYPE_SELECT,
'label' => $this->module->l('Order status when label scanned', 'orderform'),
'name' => Constant::LABEL_SCANNED_ORDER_STATUS_CONFIGURATION_NAME,
'default_value' => '0',
Expand All @@ -51,7 +51,7 @@ protected function getFields(): array
],
],
Constant::DELIVERED_ORDER_STATUS_CONFIGURATION_NAME => [
'type' => 'select',
'type' => self::FIELD_TYPE_SELECT,
'label' => $this->module->l('Order status when delivered', 'orderform'),
'name' => Constant::DELIVERED_ORDER_STATUS_CONFIGURATION_NAME,
'options' => [
Expand All @@ -61,7 +61,7 @@ protected function getFields(): array
],
],
Constant::IGNORE_ORDER_STATUS_CONFIGURATION_NAME => [
'type' => 'checkbox',
'type' => self::FIELD_TYPE_CHECKBOX,
'label' => $this->module->l('Ignore order statuses', 'orderform'),
'name' => Constant::IGNORE_ORDER_STATUS_CONFIGURATION_NAME,
'multiple' => true,
Expand All @@ -72,7 +72,7 @@ protected function getFields(): array
],
],
Constant::STATUS_CHANGE_MAIL_CONFIGURATION_NAME => [
'type' => 'switch',
'type' => self::FIELD_TYPE_SWITCH,
'label' => $this->module->l('Order status mail', 'orderform'),
'name' => Constant::STATUS_CHANGE_MAIL_CONFIGURATION_NAME,
'required' => false,
Expand All @@ -91,7 +91,7 @@ protected function getFields(): array
],
],
Constant::ORDER_NOTIFICATION_AFTER_CONFIGURATION_NAME => [
'type' => 'select',
'type' => self::FIELD_TYPE_SELECT,
'label' => $this->module->l('Send notification after', 'orderform'),
'name' => Constant::ORDER_NOTIFICATION_AFTER_CONFIGURATION_NAME,
'options' => [
Expand All @@ -111,7 +111,7 @@ protected function getFields(): array
],
Constant::SENT_ORDER_STATE_FOR_DIGITAL_STAMPS_CONFIGURATION_NAME => [
'type' => $this->getExclusiveNlFieldType(
'switch',
self::FIELD_TYPE_SWITCH,
Constant::SENT_ORDER_STATE_FOR_DIGITAL_STAMPS_CONFIGURATION_NAME
),
'label' => $this->module->l('Automatic set order state to ‘sent’ for digital stamp', 'orderform'),
Expand Down

0 comments on commit df9489d

Please sign in to comment.