Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / Configuring the Zen Cart Admin / Built-in Shipping and Payment Modules / Can I apply Flat Rate to one Category & Zone, Per Weight for all other Categories?

Can I apply Flat Rate to one Category & Zone, Per Weight for all other Categories?

Locked

Started by blackorchidcouture on 18 Jun 2010, 9:03 PM · Views: 8,361

Results 21 to 40 of 70
This thread is locked. New replies are disabled.
27 Jun 2010, 10:30 PM
#21
blackorchidcouture avatar

blackorchidcouture

Zen Follower

Join Date:
Apr 2010
Location:
Albuquerque, NM
Posts:
198
Plugin Contributions:
0

Post #21 by blackorchidcouture

I know something is wrong with what I have now because check out goes to a white page, but am I closer?

global $cart;

    //check if manufacturer alchemy is in cart 
      if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('manufacturers_id','alchemy') > 0)); {
        $manufacturer_alchemy = $_SESSION['cart']->in_cart_check('manufacturers_id','alchemy');
  
        $drop_ship_extra_charge = $manufacturer_alchemy;
 }  
   // charge dropship fee for alchemy 
     if ($drop_ship_extra_charge > 0) { 
       $cat_extra_charge = 10; 
     'cost' => ($cat_extra_charge + MODULE_SHIPPING_USPS_HANDLING); 
      echo 'An additional $10 shipping fee for Alchemy items has been applied.';
    } else {
      $cat_extra_charge = 0;
}
27 Jun 2010, 11:08 PM
#22
blackorchidcouture avatar

blackorchidcouture

Zen Follower

Join Date:
Apr 2010
Location:
Albuquerque, NM
Posts:
198
Plugin Contributions:
0

Post #22 by blackorchidcouture

Oh, and I forgot to say I didn't try to make the php count how many Alchemy products are in the cart because whether there are one or many, only one $10 fee will be added. Unless it's still necessary to count them, and that's what's messing this all up.....

28 Jun 2010, 1:22 AM
#23
ajeh avatar

ajeh

Oba-san

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

Post #23 by ajeh

You are not using the cost correctly ...

The whole section in there should look like:

    global $cart;

    //check if manufacturer alchemy is in cart 
      if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('manufacturers_id','alchemy') > 0)); {
        $manufacturer_alchemy = $_SESSION['cart']->in_cart_check('manufacturers_id','alchemy');
  
        $drop_ship_extra_charge = $manufacturer_alchemy;
      }  
   // charge dropship fee for alchemy 
      if ($drop_ship_extra_charge > 0) { 
        $cat_extra_charge = 10; 
        echo 'An additional $10 shipping fee for Alchemy items has been applied.';
      } else {
        $cat_extra_charge = 0;
      }  

        $methods = array();
        $size = sizeof($uspsQuote);
        for ($i=0; $i<$size; $i++) {
          list($type, $cost) = each($uspsQuote[$i]);

          // BOF: UPS USPS
          $title = ((isset($this->types[$type])) ? $this->types[$type] : $type);
          if(in_array('Display transit time', explode(', ', MODULE_SHIPPING_USPS_OPTIONS)))    $title .= $transittime[$type];
          /*
          $methods[] = array('id' => $type,
          'title' => ((isset($this->types[$type])) ? $this->types[$type] : $type),
          'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
          */
          $cost = preg_replace('/[^0-9.]/', '',  $cost);
          $methods[] = array('id' => $type,
                             'title' => $title,
                             'cost' => $cat_extra_charge + ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) );

        }

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

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 Jul 2010, 6:24 AM
#24
blackorchidcouture avatar

blackorchidcouture

Zen Follower

Join Date:
Apr 2010
Location:
Albuquerque, NM
Posts:
198
Plugin Contributions:
0

Post #24 by blackorchidcouture

Well, it took me this long to get my USPS webtools user id and get on their production server, so I couldn't test out these changes I made to usps.php until now.

The php is obviously correct because the usps module is showing and calculating, but it's not calculating the extra $10 fee if there are Alchemy products in the cart.

One Alchemy product alone in the cart with my zip code brought up $5.70 for shipping (and my Alchemy products are all set to 0 weight). I also tested a non-Alchemy product alone and it was over $6 (and set to .04 weight), and then added an Alchemy product, but that didn't change the shipping calculation.

Plus, I guess putting the $10 dropship fee in the USPS module is going to make it look like the Alchemy products are going to be shipped USPS? The manufacturer actually sends them Fed Ex.

Here is what I added, with what comes before and after it so you can see where I put it. Any ideas on what's missing?

// disable only when entire cart is free shipping
    if (zen_get_shipping_enabled($this->code)) {
      $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
    }

    if ($this->enabled) {
      // check MODULE_SHIPPING_USPS_HANDLING_METHOD is in
      $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_USPS_HANDLING_METHOD'");
      if ($check_query->EOF) {
        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Handling Per Order or Per Box', 'MODULE_SHIPPING_USPS_HANDLING_METHOD', 'Box', 'Do you want to charge Handling Fee Per Order or Per Box?', '6', '0', 'zen_cfg_select_option(array(\'Order\', \'Box\'), ', now())");
      }
    }

    if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_USPS_ZONE > 0) ) {
      $check_flag = false;
      $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_USPS_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
      while (!$check->EOF) {
        if ($check->fields['zone_id'] < 1) {
          $check_flag = true;
          break;
        } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
          $check_flag = true;
          break;
        }
        $check->MoveNext();
      }

      if ($check_flag == false) {
        $this->enabled = false;
      }
    }

    $this->types = array('EXPRESS' => 'Express Mail',
        'FIRST CLASS' => 'First-Class Mail',
        'PRIORITY' => 'Priority Mail',
        'PARCEL' => 'Parcel Post',
        'MEDIA' => 'Media Mail',
        'BPM' => 'Bound Printed Matter',
        'LIBRARY' => 'Library'
        );
2 Jul 2010, 2:41 PM
#25
ajeh avatar

ajeh

Oba-san

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

Post #25 by ajeh

I am not sure what it is you added and what you posted is the wrong section of code ...

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 Jul 2010, 8:15 PM
#26
blackorchidcouture avatar

blackorchidcouture

Zen Follower

Join Date:
Apr 2010
Location:
Albuquerque, NM
Posts:
198
Plugin Contributions:
0

Post #26 by blackorchidcouture

Oops, I completely cut/paste the wrong section! :lookaroun

Here's what I put and where it is in the file, I'll make my changes red:

if (is_array($uspsQuote)) {
      if (isset($uspsQuote['error'])) {
        $this->quotes = array('module' => $this->title,
                              'error' => $uspsQuote['error']);
      } else {
 
        // BOF: UPS USPS
        if (in_array('Display weight', explode(', ', MODULE_SHIPPING_USPS_OPTIONS))) {
          switch (SHIPPING_BOX_WEIGHT_DISPLAY) {
            case (0):
            $show_box_weight = '';
            break;
            case (1):
            $show_box_weight = ' (' . $shipping_num_boxes . ' ' . TEXT_SHIPPING_BOXES . ')';
            break;
            case (2):
            $show_box_weight = ' (' . number_format($usps_shipping_weight * $shipping_num_boxes,2) . TEXT_SHIPPING_WEIGHT . ')';
            break;
            default:
            $show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($usps_shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')';
            break;
          }
        }
        // EOF: UPS USPS
 
        // BOF: UPS USPS
        $this->quotes = array('id' => $this->code,
        'module' => $this->title . $show_box_weight);
        // EOF: UPS USPS
 
    global $cart;
 
   //check if manufacturer alchemy is in cart 
     if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('manufacturers_id','alchemy') > 0)); {
       $manufacturer_alchemy = $_SESSION['cart']->in_cart_check('manufacturers_id','alchemy');
 
       $drop_ship_extra_charge = $manufacturer_alchemy;
     }  
  // charge dropship fee for alchemy 
     if ($drop_ship_extra_charge > 0) { 
       $cat_extra_charge = 10; 
       echo 'An additional $10 shipping fee for Alchemy items has been applied.';
     } else {
       $cat_extra_charge = 0;
     } 
 
        $methods = array();
        $size = sizeof($uspsQuote);
        for ($i=0; $i<$size; $i++) {
          list($type, $cost) = each($uspsQuote[$i]);
 
          // BOF: UPS USPS
          $title = ((isset($this->types[$type])) ? $this->types[$type] : $type);
          if(in_array('Display transit time', explode(', ', MODULE_SHIPPING_USPS_OPTIONS)))    $title .= $transittime[$type];
          /*
          $methods[] = array('id' => $type,
          'title' => ((isset($this->types[$type])) ? $this->types[$type] : $type),
          'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
          */
          $cost = preg_replace('/[^0-9.]/', '',  $cost);
          $methods[] = array('id' => $type,
                             'title' => $title,
                             'cost' => $cat_extra_charge + ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) );
 
        }
 
        $this->quotes['methods'] = $methods;
 
        if ($this->tax_class > 0) {
          $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
        }
3 Jul 2010, 12:03 AM
#27
ajeh avatar

ajeh

Oba-san

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

Post #27 by ajeh

Change the two 'alchemy' to be the value of the manufacturers_id for alchemy ...

$_SESSION['cart']->in_cart_check('manufacturers_id','alchemy')

So if the value is 38 use:

$_SESSION['cart']->in_cart_check('manufacturers_id',38)

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!

3 Jul 2010, 12:57 AM
#28
blackorchidcouture avatar

blackorchidcouture

Zen Follower

Join Date:
Apr 2010
Location:
Albuquerque, NM
Posts:
198
Plugin Contributions:
0

Post #28 by blackorchidcouture

OK, we're super close, I changed those manufacturer id's, and now when I put an Alchemy product in the cart and put my zip, the shipping is $15.70, so it's adding the $10 on top of what usps is calculating for shipping, the only thing is that the usps shouldn't be calculating, I only need the flat $10.

Is this the reason that I needed to also configure the flat.php, for cases when there are only Alchemy products in the cart? I guess I thought the usps module would just not calculate anything because of the 0 weight and just add the dropship charge. Maybe because I haven't taken the tare off? I'll try that.....

Ok, that changed it a bit, but didn't eliminate it. The total including the $10 is coming to $11.22/first class, and $14.90/priority, so the very base amounts.

Is there a way to further change usps.php or is it time to work on flat.php?

Thank you soooooo much for all the help you've given me!

3 Jul 2010, 1:58 AM
#29
ajeh avatar

ajeh

Oba-san

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

Post #29 by ajeh

What are the shipping charges if:
1 Alchemy Product
2 Alchemy Product
3 Alchemy Product
1 Alchemy Product and 1 Regular
2 Alchemy Product and 2 Regular
3 Alchemy Product and 1 Regular
2 Alchemy Product and 2 Regular

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!

3 Jul 2010, 2:11 AM
#30
blackorchidcouture avatar

blackorchidcouture

Zen Follower

Join Date:
Apr 2010
Location:
Albuquerque, NM
Posts:
198
Plugin Contributions:
0

Post #30 by blackorchidcouture

I tested each of those, and they ALL came out to $14.90 for priority.

So with more than one Alchemy product it correctly only adds one $10 charge, but in call cases, whether it's just Alchemy products or Alchemy plus regular, it's doing the $10 plus the base priority mail charge (the two regular products are light). If I just do the two regular products and no Alchemy, it came it $4.90.....

3 Jul 2010, 2:46 AM
#31
ajeh avatar

ajeh

Oba-san

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

Post #31 by ajeh

Let's pretend I am not understanding the ultimate goal here ...

If I have other Products that are not an Alchemy product, then USPS is correct, right?

If I have 1 or more Alchemy products then it should be a Flat $10.00, correct?

What happens when I have 1 or more Alchemy products and other non-Alchemy products in the cart? Should it just add $10.00 to the USPS charge?

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!

3 Jul 2010, 3:07 AM
#32
blackorchidcouture avatar

blackorchidcouture

Zen Follower

Join Date:
Apr 2010
Location:
Albuquerque, NM
Posts:
198
Plugin Contributions:
0

Post #32 by blackorchidcouture

Yes, what you said is exactly what I want, though the alchemy flat $10 charge doesn't HAVE to be under usps since the manufacturer actually Fed Ex's them, but had come to the point that this way seemed the easiest.

Originally you had told me to set up flat.php to run if there were ONLY alchemy products, and if there were mixed products to have the usps ADD the "dropship" charge. Once I understood that a dropship charge could be added in this way, I thought I could just go the route of configuring usps.php. But now that it seems to want to add a base usps shipping price even if the weight is 0 (maybe just the nature of usps, which maybe can't be altered?), then I'm stuck again. But at least I'm closer than I was last week!

3 Jul 2010, 12:46 PM
#33
ajeh avatar

ajeh

Oba-san

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

Post #33 by ajeh

If you could tell me for sure if there should be a $10.00 charge added to the USPS rates when there are 1 or more Alchemy products in the cart and other products at the same time ...

and if there are only Alchemy products in the cart that the USPS module should be turned off and just the Flat Rate of $10.00 should be charged ... there are ways to make the modules turn on and off ...

1 Alchemy product - Flat Rate flat shows for $10.00 and USPS is turned off

2 Alchemy products - Flat Rate flat shows for $10.00 and USPS is turned off

1 Alchemy product and 1 or more other non-Alchemy products in cart - USPS shows with $10.00 added to quotes and Flat Rate flat is turned off

0 Alchemy products and other non-Alchemy products in the cart shows regular USPS quotes only and Flat Rate flat is turned off

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!

3 Jul 2010, 6:32 PM
#34
blackorchidcouture avatar

blackorchidcouture

Zen Follower

Join Date:
Apr 2010
Location:
Albuquerque, NM
Posts:
198
Plugin Contributions:
0

Post #34 by blackorchidcouture

Yes, all the scenarios you layed out are exactly true.

It sounds to me from what you're saying that I DO need the flat rate for the times that there are only alchemy products, so I'll work with that, I think that with all I've learned I'll be able to work it out, I'll post when I'm stuck or when it works.....

Thank you!

4 Jul 2010, 12:53 AM
#35
blackorchidcouture avatar

blackorchidcouture

Zen Follower

Join Date:
Apr 2010
Location:
Albuquerque, NM
Posts:
198
Plugin Contributions:
0

Post #35 by blackorchidcouture

OK, I've installed and modified flat.php, and also added some more code to usps.php, but something isn't right somewhere because the shipping options don't show up in the cart, and when I go to checkout an HTTP 500 error happens. Here's the two code changes:

In usps.php, to disable the module if only alchemy products are in the cart, which will be tested by the total cart equaling 0:

// disable only when entire cart is free shipping
    if (zen_get_shipping_enabled($this->code)) {
      $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
    }

global $cart;

// check total weight
if (IS_ADMIN_FLAG == false) {
          $chk_weight = $_SESSION['cart']->in_cart_check('products-weight','0');
      }

// disable if product weight is more than zero
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products-weight') > 0)) {
          // show USPS
          $this->enabled = true;
      } else {
          // hide USPS
          $this->enabled = false;
      } 

In flat.php, my goal is for it to check if the manufacturer Alchemy is in the cart AND if the total cart weight is 0, in which case I want it to be enabled. If the weight is more than zero and alchemy is not in the cart, it should be disabled:

// disable only when entire cart is free shipping
      if (zen_get_shipping_enabled($this->code)) {
        $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
      }

global $cart;

// check total weight and manufacturer id
if (IS_ADMIN_FLAG == false) {
          $chk_weight = $_SESSION['cart']->in_cart_check('products-weight','0');
          $chk_manufacturer = $_SESSION['cart']->in_cart_check('manufacturers_id','1');
      }

// disable if product weight is more than zero
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products-weight','0')) {
          // show FLAT
          $this->enabled = true;
      } else {
          // hide FLAT
          $this->enabled = false;
      }

// disable if no alchemy products in cart
      
      if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('manufacturers_id','1') = 0)) {
          // hide FLAT
          $this->enabled = false;
      } 

Any ideas?

4 Jul 2010, 1:44 AM
#36
ajeh avatar

ajeh

Oba-san

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

Post #36 by ajeh

Try using this to test the cart for weight:

global $cart;
// disable if product weight is more than zero in cart
if (IS_ADMIN_FLAG == false && $_SESSION['cart']->show_weight() > 0) {
  $this->enabled = false;
} else {
  $this->enabled = true;
}

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!

4 Jul 2010, 1:46 AM
#37
ajeh avatar

ajeh

Oba-san

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

Post #37 by ajeh

On testing how many are in the cart for your manufacturer ...

// disable if no alchemy products in cart
      
      if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('manufacturers_id','1') [B]=[/B]= 0)) {
          // hide FLAT
          $this->enabled = false;
      }

you missed an equal sign ...

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!

4 Jul 2010, 2:52 AM
#38
blackorchidcouture avatar

blackorchidcouture

Zen Follower

Join Date:
Apr 2010
Location:
Albuquerque, NM
Posts:
198
Plugin Contributions:
0

Post #38 by blackorchidcouture

Ok, thank you, I changed flat.php the way you suggested.

Now I'm not getting the internal error when I check out, but in the shopping cart and when I click checkout, I get this error:

1054 Unknown column 'products' in 'field list'
in:
[select products-weight as check_it from products where products_id='2' limit 1]

And depending on which product I have in the cart, the number after products_id is different.

Does this have anything to do with the shipping modules??

4 Jul 2010, 3:10 AM
#39
ajeh avatar

ajeh

Oba-san

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

Post #39 by ajeh

I need to see your code ... this is not a valid field: products-weight

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!

4 Jul 2010, 4:24 AM
#40
blackorchidcouture avatar

blackorchidcouture

Zen Follower

Join Date:
Apr 2010
Location:
Albuquerque, NM
Posts:
198
Plugin Contributions:
0

Post #40 by blackorchidcouture

Oops again!! I looked back, and realized I had products-weight instead of products_weight, so I changed three instances of it. Now the flat rate is working and showing the flat $10 charge if there are 1+ alchemy products in the cart, but if there are other products with or without any alchemy products, the USPS is not coming up at all.

The following red is ALL the custom code I've added to USPS (I've got global $cart; in there twice, is that bad?):

// disable only when entire cart is free shipping
    if (zen_get_shipping_enabled($this->code)) {
      $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
    }

global $cart;

// check total weight
if (IS_ADMIN_FLAG == false) {
          $chk_weight = $_SESSION['cart']->in_cart_check('products_weight','0');
      }

// disable if product weight is more than zero
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_weight') > 0)) {
          // show USPS
          $this->enabled = true;
      } else {
          // hide USPS
          $this->enabled = false;
      } 

//(LEAVING OUT A WHOLE SECTION OF CODE HERE TO SAVE SPACE)
// BOF: UPS USPS
        $this->quotes = array('id' => $this->code,
        'module' => $this->title . $show_box_weight);
        // EOF: UPS USPS

    global $cart;

    //check if manufacturer alchemy is in cart 
      if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('manufacturers_id','1') > 0)); {
        $manufacturer_alchemy = $_SESSION['cart']->in_cart_check('manufacturers_id','1');
  
        $drop_ship_extra_charge = $manufacturer_alchemy;
      }  
   // charge dropship fee for alchemy 
      if ($drop_ship_extra_charge > 0) { 
        $cat_extra_charge = 10; 
        echo 'An additional $10 shipping fee for Alchemy items has been applied.';
      } else {
        $cat_extra_charge = 0;
      } 

        $methods = array();
        $size = sizeof($uspsQuote);
        for ($i=0; $i<$size; $i++) {
          list($type, $cost) = each($uspsQuote[$i]);

          // BOF: UPS USPS
          $title = ((isset($this->types[$type])) ? $this->types[$type] : $type);
          if(in_array('Display transit time', explode(', ', MODULE_SHIPPING_USPS_OPTIONS)))    $title .= $transittime[$type];
          /*
          $methods[] = array('id' => $type,
          'title' => ((isset($this->types[$type])) ? $this->types[$type] : $type),
          'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
          */
          $cost = preg_replace('/[^0-9.]/', '',  $cost);
          $methods[] = array('id' => $type,
                             'title' => $title,
                             'cost' => $cat_extra_charge + ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) );

        }