Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Lost session variable - should I be doing something different?


Supertex

Recommended Posts

So the fedex web services module that's available in the addons section will pull quotes, but most of the other features don't work...specifically insurance.  Soooo...I tried to a cart value check and add the appropriate fees to the shipping method from within the module.  I couldn't get that to work.  But what I could (and did) do was calculate the appropriate fees in shopping_cart.php, and put that into a session variable:

//set insurance figures for fedex shipping methods	
	$pkg_val = $cart->show_total();
	if ($pkg_val <= 100){
		$insurancemarkup = 0;
	}else if (($pkg_val > 100)&&($pkg_val <= 300)){
		$insurancemarkup = 3;
	}else if ($pkg_val > 300){
		$insurancemarkup = (ceil($pkg_val/100));
	}
	tep_session_register ('insurancemarkup');

Then I did this in the fedexwebservices.php file itself:

 function quote($method = '') {
    /* FedEx integration starts */
    global $shipping_weight, $shipping_num_boxes, $cart, $order, $insurancemarkup;

And and then this also:

          $methods[] = array('id' => str_replace('_', '', $rateReply->ServiceType),                                                   
                             'title' => ucwords(strtolower(str_replace(array('_', ' HOME', 'DELIVERY'), array(' ', '', ''), $rateReply->ServiceType))) . '  <font color="orange">(signature may be required)</font>',
                             'cost' => $insurancemarkup + $cost + (strpos($this->types[$rateReply->ServiceType]['handling_fee'], '%') ? ($cost * (float)$this->types[$rateReply->ServiceType]['handling_fee'] / 100) : (float)$this->types[$rateReply->ServiceType]['handling_fee']));

This works fine...most of the time.  However, someone will occasionally manage to place an order and have $insurancemarkup as zero. Handling fees are correctly calculated, prices are coming back correctly...it just doesn't add the insurance.  I don't know if they're creating a cart from work and then coming home to actually place the order, or...?  Again...this is a rare occurrence but it can really cause problems; especially when I cannot replicate the error.  Is there a way to successfully make the calculations from within the module?  Have I gone about this in a foolish manner?

Thoughts?

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...