Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

default shipping method change.


Recommended Posts

Hi,

In my new shop the default shipping method is set to 0 euro, one option for customers who want tot pick up their parts in my shop.

However, many customers can't read so they chose the 0 euro option.

Can I change the default to shipping (which has to be payed for?)

On the attachment is shown what I mean.

I am sure there is a way... :-)

 

Naamloos.jpg

Link to comment
Share on other sites

I would expect a change in the checkout_ shipping.php on this line:

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

But if I comment out the entire line the shipping is not processed.

Any thoughts on this question?

Rene

Link to comment
Share on other sites

Try this and keep an eye on it if it doesn't cause any other issues.
This following code change should make the most expensive shipping selected by default.

Open catalog/includes/classes/shipping.php

FIND: (around line 108)

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

REPLACE WITH:

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

 

Link to comment
Share on other sites

If you wish to have one concrete module first you can use this code:

        $cheapest = false;
          for ($i=0, $n=sizeof($rates); $i<$n; $i++) {
            if ( $rates[$i]['id'] != 'flat_flat' ) {
              if ( is_array($cheapest) ) {
                if ($rates[$i]['cost'] < $cheapest['cost']) {
                  $cheapest = $rates[$i];
                }
              } else {
                $cheapest = $rates[$i];
              }
            }
          }

where 'flat_flat' is the flat rate shipping module, change it for the code of the shipping module you wish to show first.

Link to comment
Share on other sites

It would be nice to allow shopowner to select which module should be selected?

SQL:
Use phpmyadmin or similar

INSERT INTO configuration ( configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ( 'Set Default Shipping Method?', 'SHIPPING_DEFAULT_METHOD', '', 'This will make shipping selection default to the selected method.', '7', '5', 'tep_cfg_pull_down_shipping_methods(', now());

 

CODE:
/includes/classes/shipping.php

Find:

return $cheapest;

Add ABOVE it:

if ( defined('SHIPPING_DEFAULT_METHOD') && (SHIPPING_DEFAULT_METHOD != '--none--') ) {
  $shipping_method = basename(SHIPPING_DEFAULT_METHOD, '.php') . '_' . basename(SHIPPING_DEFAULT_METHOD, '.php');

  for ($i=0, $n=sizeof($rates); $i<$n; $i++) {
    if ($rates[$i]['id'] == $shipping_method) {
      $cheapest = $rates[$i];
    }
  }
} 

 

CODE:
/admin/includes/functions/general.php

Add:

function tep_cfg_pull_down_shipping_methods($shipping_method, $key = '') {

    $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');
    
    $shipping_array = array(array('id' => TEXT_NONE, 'text' => TEXT_NONE));
    
    $ship_array = explode(';', MODULE_SHIPPING_INSTALLED);

    foreach($ship_array as $k => $v) {
      $shipping_array[] = array('id' => $v,
                                'text' => $v);
    }

    return tep_draw_pull_down_menu($name, $shipping_array, $k);
  }

 

Note:

Untested, but should work.  Feel free to optimise it to something more elegant.

If it works, you should be able to go to admin > configuration > shipping/packaging and select which module should be used

Link to comment
Share on other sites

I recommend to everybody pivot screen. You will see the full page on most site and the world will be clear! Just realised what stupid I was before...

I understand now why nobody sitting before a cinema canvas browsing net but everybody using Full HD landscreens at home :biggrin: and tapping smart screens.
We are searching solutions but never understand the problem.
Humans read left to right or right to left. Look at a book. Is it wide? Rarely. Most are portrait. Portrait like a door. Like a walking human. Have you ever seen a landscape door?

:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Link to comment
Share on other sites

Even more simple:

Add a configuration setting if cheapest or first shipping method should be selected by default:

INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Set Default Selected Shipping Method?', 'SHIPPING_DEFAULT_METHOD_FIRST', 'true', 'Choose if default selected shipping method is cheapest (false) or first(true) in the list.', '7', '7', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now());

Then use sort order to show the desired default method first.

And in includes/classes/shipping.php:

        if ( defined('SHIPPING_DEFAULT_METHOD_FIRST') && SHIPPING_DEFAULT_METHOD_FIRST == 'true' ) {
          $cheapest = $rates[0];
        } else {        
          $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;

 

Link to comment
Share on other sites

Between: the above will also do it for different default selected shipping modules for different shipping zones.

Link to comment
Share on other sites

  • 1 month later...
On 2/3/2018 at 11:24 AM, burt said:

It would be nice to allow shopowner to select which module should be selected?

In my opinion, undoubtly yes!

Shopowner, not coder, experienced copypaster  :D

Link to comment
Share on other sites

On 2/3/2018 at 11:24 AM, burt said:

It would be nice to allow shopowner to select which module should be selected?

In my opinion, undoubtly yes!

The solution given by raiwa fits perfect for me. Thanks to all!

Shopowner, not coder, experienced copypaster  :D

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...