Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Defaultly Checked Shipping Method


Guest

Recommended Posts

The shipping page should automatically select the cheapest option as default.

Mark Evans

osCommerce Monkey & Lead Guitarist for "Sparky + the Monkeys" (Album on sale in all good record shops)

 

---------------------------------------

Software is like sex: It's better when it's free. (Linus Torvalds)

Link to comment
Share on other sites

Does anyone know how I could give my customers the ability to manually set a default shipping method and not have the system just defaultly choose the cheapest?

Link to comment
Share on other sites

I don't know if it will work or not, but you could try commenting out this part on /catalog/checkout_shipping.php:

 

// if no shipping method has been selected, automatically select the cheapest method.
// if the modules status was changed when none were available, to save on implementing
// a javascript force-selection method, also automatically select the cheapest shipping
// method if more than one module is now enabled
 if ( !tep_session_is_registered('shipping') || ( tep_session_is_registered('shipping') && ($shipping == false) && (tep_count_shipping_modules() > 1) ) ) $shipping = $shipping_modules->cheapest();

 

To comment it out, change to:

 

/*
// if no shipping method has been selected, automatically select the cheapest method.
// if the modules status was changed when none were available, to save on implementing
// a javascript force-selection method, also automatically select the cheapest shipping
// method if more than one module is now enabled
 if ( !tep_session_is_registered('shipping') || ( tep_session_is_registered('shipping') && ($shipping == false) && (tep_count_shipping_modules() > 1) ) ) $shipping = $shipping_modules->cheapest();
*/

 

I have not tested this, so I don't know whether there may be other implications along the way to removing it, so make sure you BACK UP your file before you start...

 

HTH,

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

  • 1 month later...

That may or not stop the 'cheapest default' option being selected; but how would it be possible to select the default, rather than having the cart select it?

Link to comment
Share on other sites

Sup os?

 

I was having problems with my customers using the cheapest (default) method for all their orders. I think this is because people get in a hurry. I disabled this default option by removing some code in a couple of pages. The end result..no shipping option is selected by default, forcing the user to make a selection, thus....READ.

 

Here ya go

 

part 1

includes/classes/shipping.php take out these lines(it is the last function on the page)...don't forget to complete the second part of this instruction

 

function cheapest() {

if (is_array($this->modules)) {

$rates = array();

 

reset($this->modules);

while (list(, $value) = each($this->modules)) {

$class = substr($value, 0, strrpos($value, '.'));

if ($GLOBALS[$class]->enabled) {

$quotes = $GLOBALS[$class]->quotes;

for ($i=0, $n=sizeof($quotes['methods']); $i<$n; $i++) {

if (isset($quotes['methods'][$i]['cost']) && tep_not_null($quotes['methods'][$i]['cost'])) {

$rates[] = array('id' => $quotes['id'] . '_' . $quotes['methods'][$i]['id'],

'title' => $quotes['module'] . ' (' . $quotes['methods'][$i]['title'] . ')',

'cost' => $quotes['methods'][$i]['cost']);

}

}

}

}

 

$cheapest = false;

for ($i=0, $n=sizeof($rates); $i<$n; $i++) {

if (is_array($cheapest)) {

if ($rates[$i]['cost'] < $cheapest['cost']) {

$cheapest = $rates[$i];

}

} else {

$cheapest = $rates[$i];

}

}

 

return $cheapest;

}

}

 

 

Part 2

 

catalog/checkout_shipping.php take out

 

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

 

I hope this helps. Thanks

Dr Stomp

Link to comment
Share on other sites

  • 3 months later...
  • 9 months later...

Not at all, guys, it's more simple, here is the complete and simple solution:

 

1. Open first the payment contribution you want as set as default:

2. find the line (around line 40):

$this->quotes = array('id' => $this->code,
                                'module' => MODULE_SHIPPING_ yours ! _TEXT_TITLE,

and add this just after the above:

'checked' => 'true',

 

so you should have:

$this->quotes = array('id' => $this->code,
                           'module' => MODULE_SHIPPING_ yours! _TEXT_TITLE,
    	 'checked' => 'true',
                           'methods' => array());

Save and upload.

3. Now open the /catalog/checkout_shipping.php file, and find the following code:

$checked = (($quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $shipping['id']) ? true : false);

           if ( ($checked == true) || ($n == 1 && $n2 == 1) ) {

change it to:

//$checked = (($quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $shipping['id']) ? true : false);

           //if ( ($checked == true) || ($n == 1 && $n2 == 1) ) {
if ( ($quotes[$i]['checked'] == 'true') || ($n == 1 && $n2 == 1) ) {

 

Now find a few line belong:

<td class="main" align="right"><?php echo tep_draw_radio_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'], $checked); ?></td>

and change it to:

<td width="118" align="right" valign="middle" class="main"><?php echo tep_draw_radio_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'], $quotes[$i]['checked']); ?></td>

 

That's it, you are done.

 

Save, upload, refresh and you have it !

 

Marc

Edited by thedream

osCommerce 2.2 MS2 in 6 languages

TVA Intracomm

Numbers of visitors online

Who's online Enhancement

....

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...