Forums / Built-in Shipping and Payment Modules / Need to add per item fee (based on category) to the ups module

Need to add per item fee (based on category) to the ups module

Views: 2,153

Results 1 to 20 of 22
14 Nov 2011, 9:51 PM
#1
timhersh avatar

timhersh

Zen Follower

Join Date:
Aug 2008
Posts:
274
Plugin Contributions:
0

Need to add per item fee (based on category) to the ups module

Hello,

I have been trying to figure this out for 2 hours and can't find an exact match to what I am needing online. Any help would be great.

I am using the standard ups module which is working great but my client is selling bottles of wine and we need to add a 4.95 handling fee (check id fee) which I can handle but then we need to add a .75 per bottle of wine sold for the packaging. It is based on the number of bottles they order, .75 each....There is only one five categories on my site and 2 are wines.

17 Nov 2011, 1:37 AM
#3
timhersh avatar

timhersh

Zen Follower

Join Date:
Aug 2008
Posts:
274
Plugin Contributions:
0

Re: Need to add per item fee (based on category) to the ups module

Thank you very much,

I have the shipping method working now but it is displaying two totals instead of one. Both labeled ground shipping.

The first total is correct, what I want, the second one is the original. I have tried to figure out how to remove it but can't get it to work. Any ideas what I can remove to stop the second one.

Here is my code

  global $cart;
  $chk_perishables = 0;
  $chk_perishables += $_SESSION['cart']->in_cart_check('master_categories_id','11');
  $chk_perishables += $_SESSION['cart']->in_cart_check('master_categories_id','5');
  $chk_perishables += $_SESSION['cart']->in_cart_check('master_categories_id','6');
  $chk_perishables += $_SESSION['cart']->in_cart_check('master_categories_id','7');
  $chk_perishables += $_SESSION['cart']->in_cart_check('master_categories_id','8');
  $chk_perishables += $_SESSION['cart']->in_cart_check('master_categories_id','9');
    $chk_perishables += $_SESSION['cart']->in_cart_check('master_categories_id','10');

// continue adding for more categories
$perishables_handling = 0;

    $perishables_handling = (.75 * $chk_perishables);
    // add extra handling
   
  }

// add $perishables_handling to cost
$methods[] = array('id' => $type,
'title' => $this->types[$type],
'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_UPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_UPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_UPS_HANDLING) + $perishables_handling );
// eof: customize for extra charges

Any help would be great

thanks

17 Nov 2011, 1:50 AM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Need to add per item fee (based on category) to the ups module

Could you post the code from the line that starts with:

      $methods = array();

all the way to the line:

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

It sounds like you may have left some old code in there rather than replacing it ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

17 Nov 2011, 1:53 AM
#6
timhersh avatar

timhersh

Zen Follower

Join Date:
Aug 2008
Posts:
274
Plugin Contributions:
0

Re: Need to add per item fee (based on category) to the ups module

Thank you for the help.

Here it is

 $methods = array();
  // BOF: UPS USPS
  $allowed_methods = explode(", ", MODULE_SHIPPING_UPS_TYPES);
  $std_rcd = false;
  // EOF: UPS USPS
  $qsize = sizeof($upsQuote);
  for ($i=0; $i<$qsize; $i++) {
    list($type, $cost) = each($upsQuote[$i]);
    // BOF: UPS USPS
    if ($type=='STD') {
      if ($std_rcd) continue;
      else $std_rcd = true;
    }
    if (!in_array($type, $allowed_methods)) continue;
    // EOF: UPS USPS
    $cost = preg_replace('/[^0-9.]/', '',  $cost);
	
	
	
	
	// bof: customize for extra charges
  global $cart;
  $chk_perishables = 0;
  $chk_perishables += $_SESSION['cart']->in_cart_check('master_categories_id','11');
  $chk_perishables += $_SESSION['cart']->in_cart_check('master_categories_id','5');
  $chk_perishables += $_SESSION['cart']->in_cart_check('master_categories_id','6');
  $chk_perishables += $_SESSION['cart']->in_cart_check('master_categories_id','7');
  $chk_perishables += $_SESSION['cart']->in_cart_check('master_categories_id','8');
  $chk_perishables += $_SESSION['cart']->in_cart_check('master_categories_id','9');
    $chk_perishables += $_SESSION['cart']->in_cart_check('master_categories_id','10');

// continue adding for more categories
$perishables_handling = 0;

    $perishables_handling = (.75 * $chk_perishables);
    // add extra handling
   
  }

// add $perishables_handling to cost
$methods[] = array('id' => $type,
'title' => $this->types[$type],
'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_UPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_UPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_UPS_HANDLING) + $perishables_handling );
// eof: customize for extra charges

    $methods[] = array('id' => $type,
                       'title' => $this->types[$type],
                       'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_UPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_UPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_UPS_HANDLING) );
  }

  $this->quotes['methods'] = $methods;
17 Nov 2011, 2:02 AM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Need to add per item fee (based on category) to the ups module

You left in this code:

$methods[] = array('id' => $type,
'title' => $this->types[$type],
'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_UPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_UPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_UPS_HANDLING) );
}

That was replaced with the new code:

$methods[] = array('id' => $type,
'title' => $this->types[$type],
'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_UPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_UPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_UPS_HANDLING) + $perishables_handling );

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

17 Nov 2011, 2:17 AM
#8
timhersh avatar

timhersh

Zen Follower

Join Date:
Aug 2008
Posts:
274
Plugin Contributions:
0

Re: Need to add per item fee (based on category) to the ups module

Awesome, thank you, works perfect.

One other quick question if you don't mind. I have been trying to figure this out for awhile. How do I make the background of the shipping estimator popup a different color than the main background. I am using a dark image as a background and it is showing up on the popup and I've tried to overide it.

thanks again

17 Nov 2011, 2:27 AM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Need to add per item fee (based on category) to the ups module

Perhaps a designer type can jump in and help you with that ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

17 Nov 2011, 2:39 AM
#10
timhersh avatar

timhersh

Zen Follower

Join Date:
Aug 2008
Posts:
274
Plugin Contributions:
0

Re: Need to add per item fee (based on category) to the ups module

Thank you. I have figured out how to change everything on the est page other than the background.

1 Dec 2016, 11:45 PM
#11
oldcarguy avatar

oldcarguy

New Zenner

Join Date:
Dec 2016
Location:
San Diego, CA USA
Posts:
6
Plugin Contributions:
0

Re: Need to add per item fee (based on category) to the ups module

Hi Linda,

I'm new to PHP but I was able to modify your code somewhat to my purposes. I'm trying to create 2 additional handling categories in your UPS Module. One for shipping a 4' tube to add an additional $10 to the shipping cost, and one for shipping an 8' tube to add the $10 cost of the tube, plus the mandatory $10.50 addl. handling fee for UPS. Here's my code, but it shows 2 of every shipping option in the cart, and it only takes the 4' option. Any advice is appreciated!

// bof: customize for extra charges
      global $cart;
      $chk_molding = 0;
      $chk_molding += $_SESSION['cart']->in_cart_check('master_categories_id','141');
      $chk_molding += $_SESSION['cart']->in_cart_check('master_categories_id','136');
      $chk_molding += $_SESSION['cart']->in_cart_check('master_categories_id','137');
      $chk_molding += $_SESSION['cart']->in_cart_check('master_categories_id','139');
      $chk_molding += $_SESSION['cart']->in_cart_check('master_categories_id','138');
      $chk_molding += $_SESSION['cart']->in_cart_check('master_categories_id','140');
      $chk_molding += $_SESSION['cart']->in_cart_check('master_categories_id','142');
      $chk_molding += $_SESSION['cart']->in_cart_check('master_categories_id','171');
      $chk_molding4 = 0;
      $chk_molding4 += $_SESSION['cart']->in_cart_check('master_categories_id','164');
      $chk_molding4 += $_SESSION['cart']->in_cart_check('master_categories_id','165');
      $chk_molding4 += $_SESSION['cart']->in_cart_check('master_categories_id','166');
      $chk_molding4 += $_SESSION['cart']->in_cart_check('master_categories_id','167');
      $chk_molding4 += $_SESSION['cart']->in_cart_check('master_categories_id','169');
      $chk_molding4 += $_SESSION['cart']->in_cart_check('master_categories_id','170');
// continue adding for more categories
      $molding_handling = 0;
      if ($chk_molding > 0) {
        // add tube
        $molding_handling = 10.00;
        // add extra handling
        $molding_handling += 10.50;
      } 
$molding4_handling = 0;
      if ($chk_molding4 > 0) {
        // add tube
        $molding_handling = 10.00;
      }
// add $molding_handling to cost
	$methods[] = array('id' => $type,
                           'title' => $this->types[$type],
                           'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_UPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_UPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_UPS_HANDLING) + $molding_handling );
// add $molding4_handling to cost
	$methods[] = array('id' => $type,
                           'title' => $this->types[$type],
                           'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_UPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_UPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_UPS_HANDLING) + $molding4_handling );
// eof: customize for extra charges

Thanks in advance!
Using v1.5.0 - clean install, no upgrades: http://restorationstuff.com/ecommerce
~Joe

2 Dec 2016, 12:11 AM
#12
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Need to add per item fee (based on category) to the ups module

You put the building of the cost in twice with:

// add $molding_handling to cost 
    $methods[] = array('id' => $type, 
                           'title' => $this->types[$type], 
                           'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_UPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_UPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_UPS_HANDLING) + $molding_handling ); 
// add $molding4_handling to cost 
    $methods[] = array('id' => $type, 
                           'title' => $this->types[$type], 
                           'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_UPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_UPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_UPS_HANDLING) + $molding4_handling ); 
// eof: customize for extra charges  

Change that to:

// add $molding_handling to cost 
// add $molding4_handling to cost 
    $methods[] = array('id' => $type, 
                           'title' => $this->types[$type], 
                           'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_UPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_UPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_UPS_HANDLING) + $molding_handling + $molding4_handling ); 

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

2 Dec 2016, 4:20 PM
#13
oldcarguy avatar

oldcarguy

New Zenner

Join Date:
Dec 2016
Location:
San Diego, CA USA
Posts:
6
Plugin Contributions:
0

Re: Need to add per item fee (based on category) to the ups module

Oh my goodness, you're a genius. Thank you so much!!! Only one little issue remains: If a customer orders both a 4' stick and an 8' stick of molding, the cart only applies the 4' tube charge. Is there an easy fix for that?

2 Dec 2016, 4:33 PM
#14
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Need to add per item fee (based on category) to the ups module

Are you charge 1 fee for all of the matches or 1 per each match?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

2 Dec 2016, 4:57 PM
#15
oldcarguy avatar

oldcarguy

New Zenner

Join Date:
Dec 2016
Location:
San Diego, CA USA
Posts:
6
Plugin Contributions:
0

Re: Need to add per item fee (based on category) to the ups module

Thanks for the prompt responses! Only one fee per shipment; $10 for a 4 foot tube, and $20.50 for an 8 foot tube. But if a customer needs a 4 foot and an 8 foot item we'll obviously ship them both in the 8' tube, that's where the code is only charging $10 instead of $20.50.

2 Dec 2016, 5:14 PM
#16
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Need to add per item fee (based on category) to the ups module

Try changing the code from:

// continue adding for more categories 
      $molding_handling = 0; 
      if ($chk_molding > 0) { 
        // add tube 
        $molding_handling = 10.00; 
        // add extra handling 
        $molding_handling += 10.50; 
      }  
$molding4_handling = 0; 
      if ($chk_molding4 > 0) { 
        // add tube 
        $molding_handling = 10.00; 
      } 

to be:

// continue adding for more categories 
      $molding_handling = 0; 
      if ($chk_molding > 0) { 
        // add tube 
        $molding_handling = 10.00; 
        // add extra handling 
        $molding_handling += 10.50; 
      }  
$molding4_handling = 0; 
      if ($chk_molding4 > 0) { 
        // add tube 
        $molding[B]4[/B]_handling = 10.00; 
      } 

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

2 Dec 2016, 5:53 PM
#17
oldcarguy avatar

oldcarguy

New Zenner

Join Date:
Dec 2016
Location:
San Diego, CA USA
Posts:
6
Plugin Contributions:
0

Re: Need to add per item fee (based on category) to the ups module

We're closer, but if now if the customer ordered both an 8 foot and a 4 foot it charges for both instead of just the required 8 foot tube. Seems like I need one of those magical 'else if' statements that I have no idea how to program LOL... You're amazing, coffee and donuts on me!

2 Dec 2016, 5:58 PM
#18
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Need to add per item fee (based on category) to the ups module

Okay let's try this:

// continue adding for more categories 
      $molding_handling = 0; 
      if ($chk_molding > 0) { 
        // add tube 
        $molding_handling = 10.00; 
        // add extra handling 
        $molding_handling += 10.50; 
      }  
$molding4_handling = 0; 
      if ($chk_molding4 > 0) { 
        // add tube 
        $molding4_handling = 10.00; 
      } 
      if ($chk_molding > 0 && $chk_molding4 > 0) { 
        $molding_handling = 0;
      }


Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

2 Dec 2016, 6:10 PM
#19
oldcarguy avatar

oldcarguy

New Zenner

Join Date:
Dec 2016
Location:
San Diego, CA USA
Posts:
6
Plugin Contributions:
0

Re: Need to add per item fee (based on category) to the ups module

This modification only charges for the 4' tube if I include an 8' stick :-(

2 Dec 2016, 6:17 PM
#20
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Need to add per item fee (based on category) to the ups module

Then change this from:

      if ($chk_molding > 0 && $chk_molding4 > 0) {  $molding_handling = 0;       }

to read:

      if ($chk_molding > 0 && $chk_molding4 > 0) { 
        $molding_handling = 20.50;
        $molding4_handling= 0.00;
      }

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!