Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

I've pulled together two separate shipping modules (zipship and percent ship), and actually got the result I was looking for, such that a surcharge (defined as a percentage of sale) is applied on top of a variable flat rate determined by an array of delivery zip codes and attendant delivery prices. My problem is that, though the module loaded fine, and seems to be working--i.e. the delivery fees that show up on the shipping page for the module are correct, when I click Continue, it won't advance to the credit card page. I've been sitting around all day with my php manual trying to figure out what the problem might be, but as yet I have no idea. If anyone can think of what might prevent the page from advancing even though the correct shipping price is registering, I'd appreciate a nudge in the right direction. Thanks for your time. --RC

Posted
I've pulled together two separate shipping modules (zipship and percent ship), and actually got the result I was looking for, such that a surcharge (defined as a percentage of sale) is applied on top of a variable flat rate determined by an array of delivery zip codes and attendant delivery prices. My problem is that, though the module loaded fine, and seems to be working--i.e. the delivery fees that show up on the shipping page for the module are correct, when I click Continue, it won't advance to the credit card page. I've been sitting around all day with my php manual trying to figure out what the problem might be, but as yet I have no idea. If anyone can think of what might prevent the page from advancing even though the correct shipping price is registering, I'd appreciate a nudge in the right direction. Thanks for your time. --RC

one of the reason why zipship, at least, will not move to the next screen is that it is not actually finding the zip in the "database"...make sure that zipship is not throwing off an error...if you need help send me a link and ill look at it for u.

 

- mark

Posted
one of the reason why zipship, at least, will not move to the next screen is that it is not actually finding the zip in the "database"...make sure that zipship is not throwing off an error...if you need help send me a link and ill look at it for u.

 

- mark

 

 

Mark,

 

This is what I have. The deal was, I didn't need the tables with the weights and such, since we dont' ship by weight, so I removed that variable from the module, and some of the code that referenced the table. The result is exactly what I want, if I can get the page to advance properly. Thanks for taking the time to look into it.

 

class zippateedoodah {

var $code, $title, $description, $icon, $enabled, $num_zones;

 

// class constructor

function zippateedoodah() {

 

$this->code = 'zippateedoodah';

$this->title = MODULE_SHIPPING_ZIPPATEEDOODAH_TEXT_TITLE;

$this->description = MODULE_SHIPPING_ZIPPATEEDOODAH_TEXT_DESCRIPTION;

$this->sort_order = MODULE_SHIPPING_ZIPPATEEDOODAH_SORT_ORDER;

$this->icon = '';

$this->tax_class = MODULE_SHIPPING_ZIPPATEEDOODAH_TAX_CLASS;

$this->enabled = ((MODULE_SHIPPING_ZIPPATEEDOODAH_STATUS == 'True') ? true : false);

 

// CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED

$this->num_zones = 122;

 

if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_ZIPPATEEDOODAH_ZONE > 0) ) {

$check_flag = false;

$check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_ZIPPATEEDOODAH_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");

while ($check = tep_db_fetch_array($check_query)) {

if ($check['zone_id'] < 1) {

$check_flag = true;

break;

} elseif ($check['zone_id'] == $order->delivery['zone_id']) {

$check_flag = true;

break;

}

}

 

if ($check_flag == false) {

$this->enabled = false;

}

}

}

// class methods

function quote($method = '') {

global $order, $cart;

 

if (MODULE_SHIPPING_ZIPPATEEDOODAH_STATUS == 'True') {

// edited to work with gift vouchers and 0 weight products

//$order_total = $cart->show_total();

$order_total = $cart->show_total();

// edited to work with gift vouchers and 0 weight products

}

 

$dest_zipcode = $order->delivery['postcode'];

$dest_zone = 0;

$error = false;

 

for ($i=1; $i<=$this->num_zones; $i++) {

$zipcode_table = constant('MODULE_SHIPPING_ZIPPATEEDOODAH_CODES_' . $i);

$zipcode_zones = split("[,]", $zipcode_table);

if (in_array($dest_zipcode, $zipcode_zones)) {

$dest_zone = $i;

break;

}

}

 

if ($dest_zone == 0) {

$error = true;

} else {

if ($order_total >= MODULE_SHIPPING_ZIPPATEEDOODAH_LESS_THEN) {

$shipping_cost = ($order_total * MODULE_SHIPPING_ZIPPATEEDOODAH_RATE) + constant('MODULE_SHIPPING_ZIPPATEEDOODAH_HANDLING_' . $dest_zone);

}

else {

$shipping_cost = MODULE_SHIPPING_ZIPPATEEDOODAH_FLAT_USE;

}

 

if ($shipping == -1) {

$shipping_cost = 0;

$shipping_method = MODULE_SHIPPING_ZIPPATEEDOODAH_UNDEFINED_RATE;

}

}

 

$this->quotes = array('id' => $this->code,

'module' => MODULE_SHIPPING_ZIPPATEEDOODAH_TEXT_TITLE,

'methods' => array(array('id' => $this->code,

'title' => $shipping_method,

'cost' => $shipping_cost)));

 

if ($this->tax_class > 0) {

$this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);

}

 

if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);

 

if ($error == true) $this->quotes['error'] = MODULE_SHIPPING_ZIPPATEEDOODAH_INVALID_CODE;

 

return $this->quotes;

}

 

function check() {

if (!isset($this->_check)) {

$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_ZIPPATEEDOODAH_STATUS'");

$this->_check = tep_db_num_rows($check_query);

}

return $this->_check;

}

 

function install() {

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Zipcode Method', 'MODULE_SHIPPING_ZIPPATEEDOODAH_STATUS', 'True', 'Do you want to offer Zipcode rate shipping/delivery?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_ZIPPATEEDOODAH_TAX_CLASS', '0', 'Use the following tax class on the shipping/delivery fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_ZIPPATEEDOODAH_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");

for ($i = 1; $i <= $this->num_zones; $i++) {

$default_zipcodes = '';

if ($i == 1) {

$default_zipcodes = '44136,44212,44280';

 

$default_handling= '0';

}

****************120 other zones listed here************************

 

else if ($i == 122) {

$default_zipcodes = '43968';

 

$default_handling = '167';

}

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Percentage Rate', 'MODULE_SHIPPING_ZIPPATEEDOODAH_RATE', '.18', 'The Percentage Rate all .01 to .99 for all orders using this shipping method.', '6', '0', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('A Flat Rate for orders under', 'MODULE_SHIPPING_ZIPPATEEDOODAH_LESS_THEN', '34.75', 'A Flat Rate for all orders that are under the amount shown.', '6', '0', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('A Flat Rate of', 'MODULE_SHIPPING_ZIPPATEEDOODAH_FLAT_USE', '6.50', 'A Flat Rate used for all orders.', '6', '0', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_ZIPPATEEDOODAH_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone " . $i ." Zipcode(s)', 'MODULE_SHIPPING_ZIPPATEEDOODAH_CODES_" . $i ."', '" . $default_zipcodes . "', 'Comma separated list of 5-diget zipcodes that are part of Zone " . $i . ".', '6', '0', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone " . $i ." Handling Fee', 'MODULE_SHIPPING_ZIPPATEEDOODAH_HANDLING_" . $i ."', '" . $default_handling . "', 'Handling Fee for this Zipcode', '6', '0', now())");

}

}

 

function remove() {

tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");

}

 

function keys() {

$keys = array('MODULE_SHIPPING_ZIPPATEEDOODAH_STATUS', 'MODULE_SHIPPING_ZIPPATEEDOODAH_TAX_CLASS', 'MODULE_SHIPPING_ZIPPATEEDOODAH_SORT_ORDER', 'MODULE_SHIPPING_ZIPPATEEDOODAH_RATE', 'MODULE_SHIPPING_ZIPPATEEDOODAH_LESS_THEN', 'MODULE_SHIPPING_ZIPPATEEDOODAH_FLAT_USE', 'MODULE_SHIPPING_ZIPPATEEDOODAH_ZONE');

 

for ($i=1; $i<=$this->num_zones; $i++) {

$keys[] = 'MODULE_SHIPPING_ZIPPATEEDOODAH_CODES_' . $i;

$keys[] = 'MODULE_SHIPPING_ZIPPATEEDOODAH_HANDLING_' . $i;

}

 

return $keys;

}

}

?>

Posted

rich,

 

i am thinking when you removed the weight handling table totally that perhaps it would create some sort of error condition in checkout_shipping.php in the code that actaully "instintates" the various shipping objects/modules. A better solution perhaps would have been to just set it it at "999:0"

 

The actual "bug"/error condition is *probably* being generated in checkout_shipping due to some logic error in your understanding of exactly how that page handles these external objects. You should try to run a debugger (use nusphere's phped in 3rd party mode (this will allow you to run OSC from apache, exactly as it would run normally) and "step through" checkout_shipping.php, looking at where the bug is.

 

The trial version works for a couple of weeks, but i have found that by uninstalling it and editing the registry, you can use it forever with some minor aggravation...I would strongly advise ANYONE looking to understand OSC to use this fantastic product.

 

good luck,

- mark

Posted

Thanks for both the advice and the contribution, Mark. I downloaded NuSphere and will see if I can't figure out why this isn't working. Cheers--RC

Posted

Just so you know, you were right. I added weights with 0 shipping, and it worked. The only thing I saw that didn't work initially was the handling fee, which needed to be set as: constant('MODULE_SHIPPING_ZIPSHIP_HANDLING_ . $dest_zone'); rather than constant('MODULE_SHIPPING_ZIPSHIP_HANDLING_ . $tableIdx');

 

Thanks for taking the time to point me in the right direction.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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...