Skip to content

Commit

Permalink
Merge pull request #12 from BoulangerV/M1-4-Mail_Adresse_als_Pflichtf…
Browse files Browse the repository at this point in the history
…eld_auch_in_den_Backend_Bestellungen

M1-4: Set the email address field mandatory for backend order
  • Loading branch information
BoulangerV authored Oct 16, 2019
2 parents 9bb8e34 + d67fa04 commit 1ee453e
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/design/adminhtml/base/default/layout/ratepay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,11 @@
</reference>
</adminhtml_sales_order_view>

<adminhtml_sales_order_create_index>
<reference name="head">
<action method="addJs">
<script>ratepay/adminOrderCreate.js</script>
</action>
</reference>
</adminhtml_sales_order_create_index>
</layout>
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
border-color: #2e6da4;
color: #fff;
}
.email_default_requirement_message {
color: orangered;
font-weight: bold;
background-color: bisque;
margin-top: 10px;
}
</style>

<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
Expand All @@ -74,6 +80,10 @@
</li>
<?php endif; ?>

<li class="email_default_requirement_message">
<?php echo $this->__('The email address is required for this payment method.'); ?>
</li>

<?php if ($this->isAdditionalFieldsNeeded()): ?>
<li>
<b><?php echo $this->__('Missing contact informations'); ?></b>
Expand Down Expand Up @@ -221,4 +231,7 @@
</tr>
</table>
</li>
</ul>
<script type="text/javascript">
initPaymentMethodListeners();
</script>
</ul>
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ $_paymentHelper = Mage::helper('ratepaypayment');
border-color: #ccc;
color: #333;
}
.email_default_requirement_message {
color: orangered;
font-weight: bold;
background-color: bisque;
margin-top: 10px;
}
</style>

<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
Expand All @@ -268,6 +274,10 @@ $_paymentHelper = Mage::helper('ratepaypayment');
</li>
<?php endif; ?>

<li class="email_default_requirement_message">
<?php echo $this->__('The email address is required for this payment method.'); ?>
</li>

<?php if ($this->isAdditionalFieldsNeeded()): ?>
<li>
<b><?php echo $this->__('Missing contact informations'); ?></b>
Expand Down Expand Up @@ -545,4 +555,7 @@ $_paymentHelper = Mage::helper('ratepaypayment');
<?php endif; ?>
<?php endif; ?>
</div>
<script type="text/javascript">
initPaymentMethodListeners();
</script>
</ul>
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,23 @@
font-color: #000000;
text-align: center;
}
.email_default_requirement_message {
color: orangered;
font-weight: bold;
background-color: bisque;
margin-top: 10px;
}
</style>
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
<?php if ($this->isSandbox()): ?>
<li class="ratepay-sandbox-notification">
<?php echo $this->__('Sandbox Notifcation'); ?>
</li>
<?php endif; ?>

<li class="email_default_requirement_message">
<?php echo $this->__('The email address is required for this payment method.'); ?>
</li>

<?php if ($this->isAdditionalFieldsNeeded()): ?>
<li>
Expand Down Expand Up @@ -113,4 +123,7 @@
</div>
</li>
<?php endif; ?>
<script type="text/javascript">
initPaymentMethodListeners();
</script>
</ul>
1 change: 1 addition & 0 deletions app/locale/de_DE/RatePAY_Ratepaypayment.csv
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,4 @@ wcd_sepa_terms_block_1,"Ich erm&auml;chtige die Wirecard Bank AG von meinem Kont
wcd_sepa_terms_block_2,"Ich kann innerhalb von acht Wochen, beginnend mit dem Belastungsdatum, die Erstattung des belasteten Betrages verlangen."
wcd_sepa_terms_block_3,Es gelten dabei die mit dem Kreditinstitut vereinbarten Bedingungen.
ratepay_agreement,"Es gelten die <a href='https://www.ratepay.com/legal' target='_blank'>zusätzlichen Geschäftsbedingungen und der Datenschutzhinweis</a> der RatePAY GmbH"
'The email address is required for this payment method.', 'Die E-Mail-Adresse ist für diese Zahlungsmethode erforderlich.'
69 changes: 69 additions & 0 deletions js/ratepay/adminOrderCreate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* This function is triggered to handle the email address requirement status
* Email address is mandatory for Ratepay methods
* For other methods, it should follow the standard behaviour (most probably : not required)
*/
function initPaymentMethodListeners() {
var emailField = $('email');
if ('undefined' !== typeof emailField && emailField !== null) {

// The field initialEmailRequirement is used to store the standard rule
// for email address requirement
var initialEmailRequirement = $('email_default_requirement');
if ('undefined' === typeof initialEmailRequirement || initialEmailRequirement === null) {
// If the field doesn't exist, it has to be created and appended
// next to the email address field
initialEmailRequirement = document.createElement('input');
Element.extend(initialEmailRequirement);
initialEmailRequirement.type = 'hidden';
initialEmailRequirement.id = 'email_default_requirement';
emailField.parentElement.appendChild(initialEmailRequirement);
}

// If empty, the value of the field depends on the initial requiment status of email address field
// The presence/absence of "require-entry", is considered as the standard behaviour
if (initialEmailRequirement.value === '') {
initialEmailRequirement.value = emailField.hasClassName('required-entry') ? '1' : '0';
}

// The payment method selection radio buttons are attached to a function
// that will update the requirement status of the email address field
// base on the selected payment method
var methodSwitches = $$("[id^=p_method_]");
methodSwitches.forEach(function(method) {
method.on('change', function(event) {
var target = event.target;
var methodId = target.id;
var search = methodId.search('ratepay');

if (search > -1) {
setEmailRequired(true);
}
else {
if (initialEmailRequirement.value === '1') {
setEmailRequired(true);
} else {
setEmailRequired(false);
}
}
});
});
}
}

/**
* This function (un)sets the email address field as required, based on the parameter
*
* @param required boolean
*/
function setEmailRequired(required)
{
var emailField = $('email');
if ('undefined' !== typeof emailField && emailField !== null) {
if (required) {
emailField.addClassName('required-entry');
} else {
emailField.removeClassName('required-entry');
}
}
}

0 comments on commit 1ee453e

Please sign in to comment.