Jump to content
Sign in to follow this  
tomhole

Defaultly Checked Shipping Method

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)

Share this post


Link to post
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?

Share this post


Link to post
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. *

Share this post


Link to post
Share on other sites

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?


Crouch and hold .... engage!

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

....

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×