Jump to content

Recommended Posts

Posted

Hello, how can I set Account Credit by default selected in the Checkout page, Confirm & Pay/How do you want to pay?

Right now it choose by default Payment Methods available.

Posted (edited)

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
Posted
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?

Posted

Indeed, this requires 4.4.10.

I tried to cut it down to use less of the source, but it failed if I didn't include it because its calling $paymentMethodOptions.

What would be the proper way, if you don't mind?

  • Recently Browsing   0 members

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