Jump to content

Using account credit as a payment method.


0xffset

Recommended Posts

Posted

How can I use "Account Credit" as a primary payment method.

As it stands, I need to have at least 1 active payment method to checkout. Instead I would like to just use Account Credit as the primary payment method, if the user does not have enough Account Credit it just displays an error of choice.

Thanks.

Edit:

I have done most of the work.

How can I change this code in applications/nexus/modules/front/checkout/checkout.php

        /* If we don't have any, show an error */
        if ( count( $paymentMethods ) === 0 )
        {
            \IPS\Output::i()->error( 'err_no_methods', '4X196/3', 500, 'err_no_methods_admin' );
        }

To show that error when they don't have any account credit.

Edit #2

I tried:

        $credits = \IPS\nexus\Customer::loggedIn()->cm_credits;
        if ( count( $credits ) === 0 )
        {
            \IPS\Output::i()->error( 'err_no_methods', '4X196/3', 500, 'err_no_methods_admin' );
        }

and I tried:

        $balance = array_filter( \IPS\nexus\Customer::loggedIn()->cm_credits, function( $val )
            {
                return $val->amount;
            } );
            
        if ( count( $balance ) === 0 )
        {
            \IPS\Output::i()->error( 'err_no_methods', '4X196/3', 500, 'err_no_methods_admin' );
        }

But both do not seem to achieve what I want.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...