Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
kmk Posted June 8, 2020 Posted June 8, 2020 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.
IPCommerceFan Posted June 9, 2020 Posted June 9, 2020 (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: 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 June 9, 2020 by IPCommerceFan kmk 1
kmk Posted June 9, 2020 Author Posted June 9, 2020 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: 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?
IPCommerceFan Posted June 9, 2020 Posted June 9, 2020 Yup just install it as a plugin. I tested on my dev and live site, so it should be good. kmk 1
DawPi Posted June 10, 2020 Posted June 10, 2020 Only if you have the same IPS4 version as this plugin was made from. You copied WHOLE code method and changes one line. It isnt proper way. IPCommerceFan 1
IPCommerceFan Posted June 10, 2020 Posted June 10, 2020 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?
DawPi Posted June 10, 2020 Posted June 10, 2020 Pretty easy. Look: Plugin: (DP44) Account Credit by Default on Checkout.xml Of course it's simplest way to make it, without more checks, but it's a good base. You may use it and tweak if you want to of course. kmk, BomAle, Ioannis D and 2 others 3 2
Recommended Posts