0

Hello i have one custom payment method, in that you can done payment through the credit card and debit card, i have one problem there is one checkbox "Save for the later use" , i want to hide that checkbox if customer is not login


                <!-- ko if: (hasVerification())-->
                <div class="half-width">
                    <div class="field cvv required" data-bind="attr: {id: getCode() + '_cc_type_cvv_div'}, visible: isCcFormShown">
                        <div class="control _with-tooltip">
                            <input type="password"
                                class="input-text cvv"
                                name="payment[cc_cid]"
                                value=""
                                maxlength="4"
                                data-bind="attr: {id: getCode() + '_cc_cid',
                                title: $t('Card Verification Number'),
                                placeholder:$t('Card Verification Number'),
                                'data-container': getCode() + '-cc-cvv',
                                'data-validate': JSON.stringify({'required-number':true, 'validate-cc-cvn':'#' + getCode() + '_cc_type'})},
                                enable: true,
                                value: creditCardVerificationNumber" />
                            <div class="field-tooltip toggle">
                                <span class="field-tooltip-action action-cvv"
                                    tabindex="0"
                                    data-toggle="dropdown"
                                    data-bind="attr: {title: $t('What is this?')}, mageInit: {'dropdown':{'activeClass': '_active'}}">
                                    <span><!-- ko i18n: 'What is this?'--><!-- /ko --></span>
                                </span>
                                <div class="field-tooltip-content"
                                    data-target="dropdown"
                                    data-bind="html: getCvvImageHtml()"></div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /ko -->
            </div>
            <div class="form-grp">
                <div class="field number" data-bind="">
                    <div class="control">
                        <input type="text" class="input-text" value="" maxlength="50"
                            data-bind="attr: {
                                    autocomplete: off,
                                    id: getCode() + '_cc_holder_name',
                                    title: $t('Card Holder Name'),
                                    placeholder:$t('Card Holder Name'),
                                    'data-container': getCode() + '-cc-holder-name',
                                },
                            enable: isActive($parents)"/>
                    </div>
                </div>
            </div>
            <div class="form-grp choice-wrap" >

                <div class="half-width">
                    <div class="field choice" >
                        <input type="checkbox"
                            name="vault[is_enabled]"
                            class="checkbox"
                            data-bind="attr: {'id': getCode() + '_enable_vault'}" />
                        <label class="step-title label" data-bind="attr: {'for': getCode() + '_enable_vault'}" >
                            <span><!-- ko i18n: 'Save for later use.'--><!-- /ko --></span>
                        </label>
                    </div>
                </div>

                <div class="half-width">
                    <div class="payment-method-content">
                        <div class="actions-toolbar">
                            <div class="primary">
                                <button class="action primary checkout"
                                        type="submit"
                                        data-bind="
                                        click: preparePayment,
                                        attr: {title: $t('Place Order')},
                                        enable: (getCode() == isChecked()),
                                        css: {disabled: false}
                                        "
                                        disabled>
                                    <span data-bind="text: $t('Place Order')"></span>
                                </button>
                            </div>
                        </div>
                        </div>
                    </div>
             </div>                   
        </fieldset>
    </form>


</div>

  • Which custom payment method you are using? Is any reference on GIT for that method, So we can see and update you accordingly. – Ravi Soni Jul 1 '19 at 6:05
  • If you have to custom module, Then you might get that code in HTML template. you can make it display done. – Ravi Soni Jul 1 '19 at 6:40
  • Please check my updated question @RaviSoni – Magento Jul 1 '19 at 6:42
  • Can you check my code? @RaviSoni – Magento Jul 1 '19 at 9:10
  • Here, Actually, you have to debug step by step. To identify which checkbox is there. By removing each one by one you can identify. – Ravi Soni Jul 1 '19 at 9:16
1

Please try below code.

In your html file add below condition.

<span data-bind="if: isLogedIn">
  <input type="checkbox" name="vault[is_enabled]" class="checkbox" data-bind="attr: {'id': getCode() + '_enable_vault'}" /> <label class="step-title label" data-bind="attr: {'for': getCode() + '_enable_vault'}" > <span><!-- ko i18n: 'Save for later use.'--><!-- /ko --></span> 
</span>

Next, in your KO js file add below code.

declare object of 'Magento_Customer/js/model/customer' in your define function. like this

define(
    [
        'ko',
        'uiComponent',
        'underscore',        
        'Magento_Customer/js/model/customer'
    ],
    function (
        ko,
        Component,
        _,        
        customer
    ) {
        'use strict';

        return Component.extend({
            isLogedIn: customer.isLoggedIn(),
        });
        ......

});
| improve this answer | |

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.