Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

$0 cost shipping not selected by default


tc0nn

Recommended Posts

Don't know if this has been discussed or fixed, but I had items over $40 ship free, but when the shipping methods appeared, the first non-$0 method would be selected by default. to fix:

 

Line 100 in catalog/includes/shipping.php...

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

 

simply change to:

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

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Many thanks for this quick fix - it had been a little above my PHP abilities to track this down.

 

The correct location for the file to change is: catalog/includes/classes/shipping.php

 

 

For other users trying to find this fix, some keywords:

 

Cheapest function problem issue fix

oscommerce lowest price first

free shipping postage

shipping.php

ship in cart

Link to comment
Share on other sites

  • 1 year later...

Hi,

I use an older version of oscommerce and am also trying to get it so that the "Pickup $0" option is not the default shipping method.

I have copied below my shipping.php file. Any help would be hugely appreciated.

Cheers.

 

<?php

 

class shipping {

var $modules;

 

// class constructor

function shipping() {

global $shipping_count, $language;

 

$shipping_count = 0;

if (MODULE_SHIPPING_INSTALLED) {

$this->modules = explode(';', MODULE_SHIPPING_INSTALLED); // get array of accepted modules

reset($this->modules);

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

include(DIR_WS_LANGUAGES . $language . '/modules/shipping/' . $value);

include(DIR_WS_SHIPPING_MODULES . $value);

 

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

$GLOBALS[$class] = new $class;

}

}

}

 

// class methods

function selection() {

$selection_string = '';

if (MODULE_SHIPPING_INSTALLED) {

reset($this->modules);

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

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

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

$selection_string .= $GLOBALS[$class]->selection();

}

}

$selection_string .= tep_draw_hidden_field('shipping_quote_all', '0');

}

 

return $selection_string;

}

 

function quote() {

global $total_weight, $shipping_weight, $shipping_quoted, $shipping_num_boxes;

 

if (MODULE_SHIPPING_INSTALLED) {

$shipping_quoted = '';

$shipping_num_boxes = 1;

$shipping_weight = $total_weight;

 

if ($total_weight > SHIPPING_MAX_WEIGHT) { // Split into many boxes

$shipping_num_boxes = ceil($total_weight/SHIPPING_MAX_WEIGHT);

$shipping_weight = $total_weight/$shipping_num_boxes;

}

 

if ($shipping_weight < SHIPPING_BOX_WEIGHT*SHIPPING_BOX_PADDING) {

$shipping_weight = $shipping_weight+SHIPPING_BOX_WEIGHT;

} else {

$shipping_weight = $shipping_weight + ($shipping_weight*SHIPPING_BOX_PADDING/100);

}

 

reset($this->modules);

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

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

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

$GLOBALS[$class]->quote();

}

}

}

}

 

function cheapest() {

if (MODULE_SHIPPING_INSTALLED) {

reset($this->modules);

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

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

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

$GLOBALS[$class]->cheapest();

}

}

}

}

 

function display() {

$display_string = '';

if (MODULE_SHIPPING_INSTALLED) {

reset($this->modules);

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

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

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

$display_string .= $GLOBALS[$class]->display();

}

}

}

 

return $display_string;

}

 

function confirm() {

global $shipping_cost, $shipping_method;

 

if (MODULE_SHIPPING_INSTALLED) {

$confirm_string .= '<input type="hidden" name="shipping_cost" value="' . $shipping_cost . '">' .

'<input type="hidden" name="shipping_method" value="' . $shipping_method . '">';

 

reset($this->modules);

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

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

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

$confirm_string .= $GLOBALS[$class]->confirm();

}

}

 

return $confirm_string;

}

}

}

?>

Link to comment
Share on other sites

  • 1 month later...
Hi,

I use an older version of oscommerce and am also trying to get it so that the "Pickup $0" option is not the default shipping method.

I have copied below my shipping.php file. Any help would be hugely appreciated.

Cheers.

 

<?php

 

class shipping {

var $modules;

 

// class constructor

function shipping() {

global $shipping_count, $language;

 

$shipping_count = 0;

if (MODULE_SHIPPING_INSTALLED) {

$this->modules = explode(';', MODULE_SHIPPING_INSTALLED); // get array of accepted modules

reset($this->modules);

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

include(DIR_WS_LANGUAGES . $language . '/modules/shipping/' . $value);

include(DIR_WS_SHIPPING_MODULES . $value);

 

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

$GLOBALS[$class] = new $class;

}

}

}

 

// class methods

function selection() {

$selection_string = '';

if (MODULE_SHIPPING_INSTALLED) {

reset($this->modules);

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

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

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

$selection_string .= $GLOBALS[$class]->selection();

}

}

$selection_string .= tep_draw_hidden_field('shipping_quote_all', '0');

}

 

return $selection_string;

}

 

function quote() {

global $total_weight, $shipping_weight, $shipping_quoted, $shipping_num_boxes;

 

if (MODULE_SHIPPING_INSTALLED) {

$shipping_quoted = '';

$shipping_num_boxes = 1;

$shipping_weight = $total_weight;

 

if ($total_weight > SHIPPING_MAX_WEIGHT) { // Split into many boxes

$shipping_num_boxes = ceil($total_weight/SHIPPING_MAX_WEIGHT);

$shipping_weight = $total_weight/$shipping_num_boxes;

}

 

if ($shipping_weight < SHIPPING_BOX_WEIGHT*SHIPPING_BOX_PADDING) {

$shipping_weight = $shipping_weight+SHIPPING_BOX_WEIGHT;

} else {

$shipping_weight = $shipping_weight + ($shipping_weight*SHIPPING_BOX_PADDING/100);

}

 

reset($this->modules);

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

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

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

$GLOBALS[$class]->quote();

}

}

}

}

 

function cheapest() {

if (MODULE_SHIPPING_INSTALLED) {

reset($this->modules);

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

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

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

$GLOBALS[$class]->cheapest();

}

}

}

}

 

function display() {

$display_string = '';

if (MODULE_SHIPPING_INSTALLED) {

reset($this->modules);

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

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

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

$display_string .= $GLOBALS[$class]->display();

}

}

}

 

return $display_string;

}

 

function confirm() {

global $shipping_cost, $shipping_method;

 

if (MODULE_SHIPPING_INSTALLED) {

$confirm_string .= '<input type="hidden" name="shipping_cost" value="' . $shipping_cost . '">' .

'<input type="hidden" name="shipping_method" value="' . $shipping_method . '">';

 

reset($this->modules);

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

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

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

$confirm_string .= $GLOBALS[$class]->confirm();

}

}

 

return $confirm_string;

}

}

}

?>

 

Hi-

Oops, you are using quite old version of Oscommerce.

In newer version you would edit the shipping.php class file, but the version you are using. You would edit the modules/shipping/item.php.

Just make the cheapest() return $shipping_cheapest = 'item';

That shall work for any shipping methods that you want to make default selected.

Go to the corresponding module file and modify the cheapest().

_

Thanks

kashif

Link to comment
Share on other sites

  • 7 years later...

10 years after this original thread, I made the code change recommended in the top post by tc0nn, and it worked! 

 

My situation - my site is set up to default to the cheapest of two shipping methods, Priority Mail and Express Mail.  Today, I decided to offer free Priority Mail shipping, but in making it free, the site now defaulted to Express Mail (certainly not the cheapest).  After reading many, many threads on this topic, I stumbled upon this one, and my problem was solved!

 

Thank you!!

Edited by krdito
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...