Jump to content

Account Credit by default


Recommended Posts

Hi,

There isn't a built-in option to make Account Credit the default option, however this plugin will do it!

Commerce - Account Credit by Default.xml

 

Account Credit selected by default at checkout:

image.png.34112cf0c54ff8cd6c1cea0ceb063f98.png

This modifies  \IPS\nexus\modules\front\checkout\checkout, and is actually just one small change to the form.  Instead of the default option being NULL, it is now 0.  (Account Credit is technically payment method 0).  If there is no account credit, it goes back to not making a specific default selection (NULL):

		if ( \count( $paymentMethodOptions ) > 1 )
		{
            if ( \IPS\nexus\Customer::loggedIn()->cm_credits[ $this->invoice->currency ]->amount->isGreaterThanZero() )
            {
            $form->add( new \IPS\Helpers\Form\Radio( 'payment_method', 0, TRUE, array( 'options' => $paymentMethodOptions, 'toggles' => $paymentMethodsToggles ) ) ); //0 after 'payment_method' means 0 aka account credit will be the default payment method.    
            }
            else
            {
			$form->add( new \IPS\Helpers\Form\Radio( 'payment_method', NULL, TRUE, array( 'options' => $paymentMethodOptions, 'toggles' => $paymentMethodsToggles ) ) );
            }
		}

Hope this helps!

Edited by IPCommerceFan
Link to comment
Share on other sites

2 hours ago, IPCommerceFan said:

Hi,

There isn't a built-in option to make Account Credit the default option, however this plugin will do it!

Commerce - Account Credit by Default.xml 17.38 kB · 0 downloads

 

Account Credit selected by default at checkout:

image.png.34112cf0c54ff8cd6c1cea0ceb063f98.png

This modifies  \IPS\nexus\modules\front\checkout\checkout, and is actually just one small change to the form.  Instead of the default option being NULL, it is now 0.  (Account Credit is technically payment method 0).  If there is no account credit, it goes back to not making a specific default selection (NULL):


		if ( \count( $paymentMethodOptions ) > 1 )
		{
            if ( \IPS\nexus\Customer::loggedIn()->cm_credits[ $this->invoice->currency ]->amount->isGreaterThanZero() )
            {
            $form->add( new \IPS\Helpers\Form\Radio( 'payment_method', 0, TRUE, array( 'options' => $paymentMethodOptions, 'toggles' => $paymentMethodsToggles ) ) ); //0 after 'payment_method' means 0 aka account credit will be the default payment method.    
            }
            else
            {
			$form->add( new \IPS\Helpers\Form\Radio( 'payment_method', NULL, TRUE, array( 'options' => $paymentMethodOptions, 'toggles' => $paymentMethodsToggles ) ) );
            }
		}

Hope this helps!

Thanks you so much...I will try..

Sorry, I just download your file then install it as a plugin?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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