1

I want to show the payment method with the cash on delivery option already selected when the customer comes to the payment option so if they want to use COD they can just proceed to next step and if they want to change they can choose their desired payment options. I don't know how to achieve this and I tried google but no help at all. Please help.

jon snow
  • 3,062
  • 1
  • 19
  • 31
Noob
  • 51
  • 1
  • 5

1 Answers1

0

Just Use Jquery....

  1. Inspect the element
  2. Find the Class or ID
  3. Check the button by default when the page loads

for eg, if the id of the radio button is "payment_cash_on_delivery",

$("#payment_cash_on_delivery").prop( "checked", true );

include this script in the checkout template or in the footer.

UPDATE

jQuery(document).ready(function() {
 jQuery("#payment_cash_on_delivery").prop( "checked", true );
});
anz
  • 987
  • 7
  • 21
  • where do I place this script?? payment.phtml or method.phtml – Noob May 26 '15 at 06:29
  • It doesnot matter where u place it, as long as the template is loaded in the specific URL. But for your convenience, it would be easier to track these changes later if you use a external js file, or in footer.phtml . – anz May 26 '15 at 06:32
  • I place the following code in footer.phtml but it didn't work. since i am working in a local host i used check / money order. – Noob May 26 '15 at 06:37
  • have u used jquery in your magento project previously. If no, then u need to put jQuery.noconflict(), Google for more info.. Use jquery document.ready to allow the page to fully load. This is Jquery 101, man. – anz May 26 '15 at 06:41
  • Check the updated answer above. If it doesn't work, check the console for js errors, and place the error message. – anz May 26 '15 at 08:48
  • Dude Its working cool i had to put it on methods.phtml to make it work. Works like a charm thanks a lot.. – Noob May 26 '15 at 10:09
  • I have one more doubt is it possible to simulate a click on anchor tag?? – Noob May 26 '15 at 10:13
  • $('.free').click( function(e){e.prevent default(); // now do whatever u like });. I didn't test it as I'm on my mobile at the moment. Put this inside jquery document.ready function. – anz May 27 '15 at 14:11