0

Need to add an input field below the Cash on delivery radio button.

Implemented the code by this link where the input is added below COD radio but the value is not added to the database.

Can anyone check what the wrong is on that code else provide the best solution to accomplish this?

Thanks in advance !!!!

  • can you post your observer code? – fmsthird Jan 30 '19 at 11:55
  • You can find the observer code from the below link github.com/Ejilarasan/Magento2.2.5.git – Ejilarasan J Jan 30 '19 at 12:18
  • that code seems to save the payment data in relation to the payment method selected. – fmsthird Jan 30 '19 at 12:22
  • Is that possible for you to modify as per my requirement?. The input should be below "COD" radio button and once the place order is clicked that input data should save on quote_payment table. – Ejilarasan J Jan 30 '19 at 12:26
  • I will try and post the solution here. assuming you have your own custom module already – fmsthird Jan 30 '19 at 12:27
0

Just add banktransfer.html inside Ibnab/CustomAttribute/view/frontend/web/template

<div class="payment-method" data-bind="css: {'_active': (getCode() == isChecked())}">
    <div class="payment-method-title field choice">
        <input type="radio"
               name="payment[method]"
               class="radio"
               data-bind="attr: {'id': getCode()}, value: getCode(), checked: isChecked, click: selectPaymentMethod, visible: isRadioButtonVisible()" />
        <label data-bind="attr: {'for': getCode()}" class="label"><span data-bind="text: getTitle()"></span></label>
    </div>
    <div class="payment-method-content">
        <p data-bind="html: getInstructions()"></p>
        <fieldset data-bind="attr: {class: 'fieldset payment items allbank ' + getCode(), id: 'payment_form_' + getCode()}">
            <div class="field _required">
                <label data-bind="attr: {for: getCode() + '_bankowner'}" class="label">
                    <span><!-- ko i18n: 'Account Owner'--><!-- /ko --></span>
                </label>
                <div class="control">
                    <input data-validate="{'required-entry':true}" type="text" name="payment[bankowner]" class="input-text" value=""
                           data-bind="attr: {
                                    id: getCode() + '_bankowner',
                                    title: $t('Account Owner'),
                                    'data-container': getCode() + '-bankowner',
                                    'data-validate': JSON.stringify({'required':true})},
                                    valueUpdate: 'keyup' "/>
                </div>
            </div>
        </fieldset>
        <!-- ko foreach: getRegion('messages') -->
        <!-- ko template: getTemplate() --><!-- /ko -->
        <!--/ko-->
        <div class="payment-method-billing-address">
            <!-- ko foreach: $parent.getRegion(getBillingAddressFormName()) -->
            <!-- ko template: getTemplate() --><!-- /ko -->
            <!--/ko-->
        </div>
        <div class="checkout-agreements-block">
            <!-- ko foreach: $parent.getRegion('before-place-order') -->
            <!-- ko template: getTemplate() --><!-- /ko -->
            <!--/ko-->
        </div>
        <div class="actions-toolbar">
            <div class="primary">
                <button class="action primary checkout"
                        type="submit"
                        data-bind="
                        click: placeOrder,
                        attr: {'title': $t('Place Order')},
                        enable: (getCode() == isChecked()),
                        css: {disabled: !isPlaceOrderActionAllowed()}
                        "
                        disabled>
                    <span data-bind="i18n: 'Place Order'"></span>
                </button>
            </div>
        </div>
    </div>
</div>

Change template in banktransfer-method.js
from:

 template: 'Ibnab_Additional/payment/banktransfer' 

to :

 template: 'Ibnab_CustomAttribute/banktransfer'

Then run setup:upgrade
run static-content:deploy

And check if it works!

  • Really thanks for your effort but the above changes also not working as expected. It's not added on the Admin's sales detail and the table "quote_payment" too. Can you please review it from your end? – Ejilarasan J Feb 6 '19 at 7:14
  • have you downloaded the updated module here github.com/fmsthird/magentocustomPaymentField ? – fmsthird Feb 6 '19 at 7:17
  • It works on mine. – fmsthird Feb 6 '19 at 7:17
  • Let me download the whole module from the git and try again now. – Ejilarasan J Feb 6 '19 at 7:17
  • alright. Great . hopefully it will work for you – fmsthird Feb 6 '19 at 7:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.