Jump to content
Latest News: (loading..)

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


Not too experienced, but very willing to learn.

Share this post


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


Not too experienced, but very willing to learn.

Share this post


Link to post
Share on other sites
Posted (edited)

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']) {

 

Edited by Tsimi

Share this post


Link to post
Share on other sites

Hi Tsimi,

Yes this worked for me, MANY THANKS!

Rene


Not too experienced, but very willing to learn.

Share this post


Link to post
Share on other sites
Posted (edited)

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.

Edited by raiwa

Share this post


Link to post
Share on other sites
Posted (edited)

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

Edited by burt

This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


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

Share this post


Link to post
Share on other sites

@burt

If your suggestion works (and I see no reason it shouldn't), maybe this should be added to the core? :cool:

Malcolm


If you are running the "official" osC 2.3.4 or 2.3.4.1 download, your installation is obsolete! Get the latest community-supported responsive "Edge" release here

Share this post


Link to post
Share on other sites
Posted (edited)

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;

 

Edited by raiwa

Share this post


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


Shopowner, not coder, experienced copypaster  :D

Share this post


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

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

×