Customer Credit payment option visibility

Bart Lewandowski asked on July 24, 2018 11:11

Any idea how to restrict unregistered customers from seeing the Credit Payment option on 'Choose payment type' list? Ideally I would want to show that payment option just to these whose customer credit can cover the order amount. Cheers!

Recent Answers


vasu yerramsetti answered on July 24, 2018 12:37

Hi,

You can set Display Roles to"_authenticated_" on Payment Method Web part configuration.

Please check.

0 votesVote for this answer Mark as a Correct answer

Bart Lewandowski answered on July 26, 2018 17:21

Thank you Vasu, but I know I can hide the whole web part. I need to hide just one option from that web part though. I still want the customer to be able to pay with payment card or paypal.

0 votesVote for this answer Mark as a Correct answer

Suneel Jhangiani answered on July 26, 2018 20:47 (last edited on July 26, 2018 20:50)

You might be to do this by implementing CustomPaymentOptionInfoProvider and overriding the GetPaymentOptions(int siteId, bool onlyEnabled) method. You would first customize the PaymentOption class by adding a field to indicate if the payment should be allowed for authenticated users or not. Then in the custom GetPaymentOptions method you would check if the current user is authenticated.

The code would look similar to this (note the custom field is named AllowPublic):

protected override ObjectQuery<PaymentOptionInfo> GetPaymentOptionsInternal(int siteId, bool onlyEnabled)
{
    var query = base.GetPaymentOptionsInternal(siteId, onlyEnabled);

    if (MembershipContext.AuthenticatedUser == null)
    {
        query.WhereEquals("AllowPublic", true); 
    }
    else
    {
        query.WhereEquals("AllowPublic", false);
    }
}

Note: this may have an adverse affect in other areas of Kentico and you should check. A key is that a store admin could still choose the credit payment option for a non-authenticated customer.

0 votesVote for this answer Mark as a Correct answer

Bart Lewandowski answered on July 27, 2018 17:58

Thank you Suneel. I hoped I would be able to avoid overriding standard functionalities. After all you can assign a credit only to the registered customer, so I thought that maybe I'm missing something (why showing this as an option to unregistered customers if they can't use it in the first place?). Oh well. I will try to override it and let you know if it worked.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.