Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

UPSXML flat rate for Ground shipping


DefelRadar

Recommended Posts

I've dug around in the forums to try and find an answer to my situation to no avail. What I am wanting to do is modify the upsxml.php file in includes/modules/shipping/ to give me a flat rate for UPS ground shipping while I still receive a quote for the other methods I have selected.

 

I've played around with the following code in the UPSXML module and not had much success. The bolded text is where I try to manipulate the cost of the ground shipping quote but it bombs out on me. Has anyone else had any success putting a flat rate in for the UPS ground quote on the UPSXML contrib?

 

Thanks,

 

Aaron

 

$upsQuote = $this->_upsGetQuote();

if ((is_array($upsQuote)) && (sizeof($upsQuote) > 0)) {

if ($this->dimensions_support > 0) {

$this->quotes = array('id' => $this->code, 'module' => $this->title . ' (' . $this->boxCount . ($this->boxCount > 1 ? ' pkg(s), ' : ' pkg, ') . round($totalWeight,0) . ' ' . strtolower($this->unit_weight) . ' total)');

} else {

$this->quotes = array('id' => $this->code, 'module' => $this->title . ' (' . $shipping_num_boxes . ($this->boxCount > 1 ? ' pkg(s) x ' : ' pkg x ') . round($shipping_weight,0) . ' ' . strtolower($this->unit_weight) . ' total)');

}

$methods = array();

for ($i=0; $i < sizeof($upsQuote); $i++) {

list($type, $cost) = each($upsQuote[$i]);

// BOF limit choices, behaviour changed from versions < 1.2

if (exclude_choices($type)) continue;

// EOF limit choices

if ( $method == '' || $method == $type ) {

$_type = $type;

 

if ($this->timeInTransitView == "Raw") {

if (isset($this->servicesTimeintransit[$type])) {

$_type = $_type . ", ".$this->servicesTimeintransit[$type]["date"];

}

} else {

if (isset($this->servicesTimeintransit[$type])) {

$eta_array = explode("-", $this->servicesTimeintransit[$type]["date"]);

$months = array (" ", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

$eta_arrival_date = $months[(int)$eta_array[1]]." ".$eta_array[2].", ".$eta_array[0];

$_type .= ", <acronym title='Estimated Delivery Date'>EDD</acronym>: ".$eta_arrival_date;

}

}

 

// changed to make handling percentage based

if ($this->handling_type == "Percentage") {

$methods[] = array('id' => $type, 'title' => $_type, 'cost' => ((($this->handling_fee * $cost)/100) + $cost));

} else {

$methods[] = array('id' => $type, 'title' => $_type, 'cost' => ($this->handling_fee + $cost));

}

//AMH playing around with flat shipping for UPS

if ($i = 0) {

$methods[] = array('id' => $type, 'title' => $_type, 'cost' => ($this->handling_fee));

}

}

}

if ($this->tax_class > 0) {

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

}

$this->quotes['methods'] = $methods;

Link to comment
Share on other sites

I figured it out within minutes after posting my problem.

 

Here is the solution to all those who are interested: You have to check for $i == 0 before you get into checking what kind of handling_type you have then all things will work great.

 

//AMH playing around with flat shipping for UPS

 

if ($i ==0){$methods[] = array('id' => $type, 'title' => $_type, 'cost' => (($this->handling_fee + 5) * $shipping_num_boxes));

} else {

// changed to make handling percentage based

if ($this->handling_type == "Percentage") {

$methods[] = array('id' => $type, 'title' => $_type, 'cost' => ((($this->handling_fee * $cost)/100) + $cost));

} else {

$methods[] = array('id' => $type, 'title' => $_type, 'cost' => ($this->handling_fee + $cost));

}

}

Link to comment
Share on other sites

If you want to restrict the flat shipping to a country (i.e. US) then replace the code starting around line 333 and ending at 340 with the following code:

 

if ($i ==0 AND $order->delivery['country']['iso_code_2']=='US'){$methods[] = array('id' => $type, 'title' => $_type, 'cost' => (($this->handling_fee + 5) * $this->boxCount));

} else {

// changed to make handling percentage based

if ($this->handling_type == "Percentage") {

$methods[] = array('id' => $type, 'title' => $_type, 'cost' => ((($this->handling_fee * $cost)/100) + $cost));

} else {

$methods[] = array('id' => $type, 'title' => $_type, 'cost' => ($this->handling_fee + $cost));

}

}

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