skip to Main Content

I want to make a simple change in my OSCommerce webstore. To uncheck a radio button that is now checked my default. Many customers don’t bother to read the page and they just click ‘next’. So i want to have no default value checked so the customer is forced to make a choice.

So i used FireBug to find the source code under the button which is:

<td align="right"><input type="radio" name="shipping" value="flat_flat" checked="checked" /></td>

To a PHP newby like me it seems i just just remove checked=”checked”.

However i found it impossible to find in which PHP file i should make the modification. The page itself is named ‘checkout_shipping.php’ but upon inspection of the php file it is not there.

So i downloaded the COMPLETE webstore and used Agent ransack to search each and every file.

Nothing!

Can anyone help me to figure this out? I would appreciate the help

2

Answers


  1. Might be easier to use jQuery to manipulate an element once the page has fully rendered the form.

    Some samples (either should work, providing alternates “just in case”):

    • $('input[type="radio"][name="shipping"]').removeAttr("checked");
    • $('input[type="radio"][name="shipping"]').attr("checked", false);
    • $('input[type="radio"][name="shipping"]').prop("checked", false);

    However I’m not sure which page you’d be adding this code to. I guess if there’s a view page that renders the content first, such as a /directory/view/index.php type of file?

    Login or Signup to reply.
  2. Actually, HTML for that input is dynamically created in the checkout_shipping.php file by the function tep_draw_radio_field. There’s a block of code that loops through each available shipping module and creates a radio for each one.

    The “checked” default is actually a cause of the shipping class’s cheapest() method being run higher up in the same file.

    You could comment this line of code by changing it from:

    if ( !tep_session_is_registered('shipping') || ( tep_session_is_registered('shipping') && ($shipping == false) && (tep_count_shipping_modules() > 1) ) ) $shipping = $shipping_modules->cheapest();
    

    To:

    //if ( !tep_session_is_registered('shipping') || ( tep_session_is_registered('shipping') && ($shipping == false) && (tep_count_shipping_modules() > 1) ) ) $shipping = $shipping_modules->cheapest();
    

    That should leave all of the radios unchecked on the user’s initial visit to the shipping page. Also, it leaves intact the default selected radio if the user comes back to the shipping page later in the checkout process to change their shipping method.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search