Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Customized shipping modules not working after upgrade

Customized shipping modules not working after upgrade

Views: 2,317

Results 1 to 20 of 28
23 May 2011, 3:22 AM
#1
blackorchidcouture avatar

blackorchidcouture

Zen Follower

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

Customized shipping modules not working after upgrade

Hello. So a while back Ajeh patiently helped me customize my USPS and flat rate module files so that if a certain product were in my cart a flat fee would be added in addition to any other shipping fee for the regular products, and it was working out.

A few months ago I upgraded to 1.3.9h, and I've just gotten around to testing out the checkout process, and now if I have one of these special products in the cart that would trigger the added flat rate, it just goes to a blank page and shows the paragraph I had written in to explain the flat fee. There's no way to continue, so no way to check out. I'm attaching a screen shot of what it looks like. If I remove this product and just have regular USPS triggered, it works as it should, it calculates the shipping charge by weight and there are no errors in the checkout process.

I looked at my debug logs and it says this:

[22-May-2011 14:27:01] PHP Warning: Cannot modify header information - headers already sent by (output started at ....../store/includes/modules/shipping/usps.php:276) in ..../store/includes/functions/functions_general.php on line 45

Here is line 276 in usps.php, it is part of the customized code:

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 = 5; 
        echo '<br /><font color="#660000" size="2"><em>A flat $5 shipping fee to cover all Alchemy items in your cart has been added to the shipping quote below. Please note that Alchemy products ordered from Black Orchid Couture can only be shipped to addresses in the United States. All Alchemy products are special ordered from England and will be mailed to you separate from any other items in your order, and will take between 2-3 weeks to be delivered.</em></font>';
      } else {
        $cat_extra_charge = 0;
      }

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

The question is, did some part of the usps.php code change that would interfere with the custom code above? Or maybe I made a mistake in transfering it to the new code? I'm just not sure how to interpret the error log, I looked at the other file (functions_general.php) and there is no custom code in there. I just don't know how to fix this other than installing the usps.php fresh and starting over trying to figure out how to customize it.

Thanks for any help!!!!

23 May 2011, 3:37 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Customized shipping modules not working after upgrade

Insure that in the upgrade, that you checked for any files that had new versions - especially those that you edited/cloned for this

Blank page issues in general

23 May 2011, 3:57 AM
#3
ajeh avatar

ajeh

Oba-san

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

Re: Customized shipping modules not working after upgrade

Take out the echo that you have in there ... does it work now? :unsure:

23 May 2011, 4:52 AM
#4
blackorchidcouture avatar

blackorchidcouture

Zen Follower

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

Re: Customized shipping modules not working after upgrade

Ok, I took out the echo and it's now going to the regular checkout page, so that fixed going to the blank page, thanks! BUT, it's not applying the $5.00 flat shipping fee on top of the regulara USPS fee (I put a regular item and a special item).

The thing is this used to work, it would apply the $5.00 flat fee and also include my echoed paragraph. But this is better than a complete error!

23 May 2011, 5:06 AM
#5
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Customized shipping modules not working after upgrade

Why do you not just apply in the shipping module setup a $5.00
Handling Fee

All using stock code

23 May 2011, 5:14 AM
#6
blackorchidcouture avatar

blackorchidcouture

Zen Follower

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

Re: Customized shipping modules not working after upgrade

kobra:

Why do you not just apply in the shipping module setup a $5.00
Handling Fee

All using stock code

That's an intersting idea on how to do it, but I'd have to set it up so that the $5.00 handling fee only got charged if there were any products from this particular category/manufacturer. I'm thinking customizing the code is the only way to do this? But I haven't ever looked at how to add a handling fee. Would this be in the USPS module?

23 May 2011, 5:54 AM
#7
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Customized shipping modules not working after upgrade

only got charged if there were any products from this particular category/manufacturer.

But I haven't ever looked at how to add a handling fee. Would this be in the USPS module?
Did you clone the USPS module for the specific cat thing??

Then handling fee would be set in that cloned module setup in the admin

Depending on the age of what you upgraded from...

You might need to merge your customizations into the most recent USPS module

23 May 2011, 6:18 AM
#8
blackorchidcouture avatar

blackorchidcouture

Zen Follower

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

Re: Customized shipping modules not working after upgrade

I didn't clone any shipping module, I customized both the flat rate and the USPS files to look for the product category and also look for weight, as I set these products to zero weight. So if the whole cart is zero weight, then it means that only this category is in the cart, so only the flat rate gets activated. If there is any weight in the cart, it looks for whether or not this one product category is in the cart, if not then only the USPS module is activated. If the cart is mixed, it uses both.

In terms of the latest USPS module, I had updated it when Ajeh put out the latest one in January, I merged the custom code in with the updated code.

I will have to explore cloning shipping modules more as well as adding a handling fee. If I can add a $5.00 handling fee just if any products from this one category are in the cart, I could just use the USPS module and it should work. I will look more closely at all this tomorrow....

Thanks!

23 May 2011, 2:02 PM
#9
ajeh avatar

ajeh

Oba-san

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

Re: Customized shipping modules not working after upgrade

What are you doing with the:
$cat_extra_charge

in the rest of the code? :unsure:

23 May 2011, 8:39 PM
#10
blackorchidcouture avatar

blackorchidcouture

Zen Follower

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

Re: Customized shipping modules not working after upgrade

I will show you all the custom code on the USPS and flat files. Now that I look at it, that is the only place that $cat_extra_charge shows up.

Towards the beginning of usps.php:

global $cart;

// check cart weight
  if (IS_ADMIN_FLAG == false) {  
    $chk_products_weight = $_SESSION['cart']->show_weight();
  }


// enable if total product weight is more than zero
  if (IS_ADMIN_FLAG == false && $chk_products_weight > 0) {
    // show USPS
    $this->enabled = true;
  } else {
    $this->enabled = false;
  }

Later in usps.php, I'll inlude some of the code that comes after so you can see where it is:

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 = 5; 
        } else {
        $cat_extra_charge = 0;
      }

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

// fix new trademark and reg 01-02-2011
//$type = str_replace('&lt;sup&gt;&amp;reg;&lt;/sup&gt;', '<sup>®</sup>', $type);
//$type = str_replace('&lt;sup&gt;&amp;trade;&lt;/sup&gt;', '<sup>™</sup>', $type);

In flat.php:

global $cart;

// check total cart weight
  if (IS_ADMIN_FLAG == false) {  
    $chk_products_weight = $_SESSION['cart']->show_weight();
  }

// enable if total product weight is 0 
  if (IS_ADMIN_FLAG == false && $chk_products_weight == 0) {
    // show FLAT
    $this->enabled = true;
  } else {
    // hide FLAT
    $this->enabled = false;
  }
23 May 2011, 10:36 PM
#11
ajeh avatar

ajeh

Oba-san

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

Re: Customized shipping modules not working after upgrade

Do you anywhere in the code add this value:
$cat_extra_charge

to the $cost or something so it is included? :unsure:

24 May 2011, 4:58 AM
#12
blackorchidcouture avatar

blackorchidcouture

Zen Follower

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

Re: Customized shipping modules not working after upgrade

Gotcha, yes, I left this very little but all important piece of the puzzle out:

'cost' => $cat_extra_charge + ($cost * $shipping_num_boxes)

Thank you! It's now adding the $5.00 extra cost! :P

In terms of the echo I had added to explain the whole deal about the added shipping cost, is there a reason why it wasn't working with it, and taking out the echo fixed the blank page error? I'd really like to have this paragraph in there.

One more question, I now have another product with a similar situation, I need to apply a flat rate to this whole category but it will be a different amount than the $5.00, so I need to write more code for it. I'm sure I can figure out how to duplicate it for this, but my main question is would I just add the new code to these same files, or should I make a clone of the usps.php and in the second one have the customized code for the new product? Guess I'm not sure why or when you'd want to clone a shipping module.

THANK YOU!!!!!!!!!!!!!!!!!!!!!!

24 May 2011, 2:17 PM
#13
ajeh avatar

ajeh

Oba-san

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

Re: Customized shipping modules not working after upgrade

You would just do the same thing based on the different information such as using the master_categories_id ...

24 May 2011, 7:01 PM
#14
blackorchidcouture avatar

blackorchidcouture

Zen Follower

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

Re: Customized shipping modules not working after upgrade

Wouldn't I clone the flat if I want a different flat rate for the other product?

24 May 2011, 10:55 PM
#15
ajeh avatar

ajeh

Oba-san

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

Re: Customized shipping modules not working after upgrade

Sorry, yes ... you need to clone Flat Rate flat for the new rate and Category and on the USPS you need to add the new calculation just like you had the other one ...

29 May 2011, 7:32 AM
#16
blackorchidcouture avatar

blackorchidcouture

Zen Follower

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

Re: Customized shipping modules not working after upgrade

After much thought, and trying to configure the two cloned flat rates (and after studying code in other similar posts), I finally realized that I think this can be done with just one flat.php file.

The usps.php is working perfectly, if the weight of the items in the cart is more than 0 it is activated, and if there are manufacturers 1 and or 2 in the cart it adds the appropriate extra flat fees.

I used basically the same code in the flat.php, if the total cart weight is 0 it is activated, then it is supposed to look for manufacturers 1 & 2 and add the correct flat fees together.

My thought is to configure the flat fee under shipping modules in my admin to be $0, and then just have the extra flat fees added.

I know something is wrong with this file, because once I added the extra code in, the shipping modules don't show in my admin. Take the code out, and they show.

Here is my custom code in the flat.php:

global $cart;

// check total cart weight
  if (IS_ADMIN_FLAG == false) {  
    $chk_products_weight = $_SESSION['cart']->show_weight();
  }

// enable if total product weight is 0 
  if (IS_ADMIN_FLAG == false && $chk_products_weight == 0) {
    // show FLAT
    $this->enabled = true;
  } else {
    // hide FLAT
    $this->enabled = false;
  }

    //check if manufacturer 1 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_one = $manufacturer_alchemy;
      }  

   // charge dropship fee for manufacturer 1 
       if ($drop_ship_extra_charge_one > 0) { 
        $cat_extra_charge_one = 5; 
        } else {
        $cat_extra_charge_one = 0;
      }

//check if manufacturer 2 is in cart 
      if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('manufacturers_id','2') > 0)); {
        $manufacturer_femme_metale = $_SESSION['cart']->in_cart_check('manufacturers_id','2');  
        $drop_ship_extra_charge_two = $manufacturer_femme_metale;
      }
  
   // charge dropship fee for manufacturer 2
      if ($drop_ship_extra_charge_two > 0) { 
        $cat_extra_charge_two = 10; 
        } else {
        $cat_extra_charge_two = 0;
      }

and for the cost part I did this:

'cost' => $cat_extra_charge_one + $cat_extra_charge_two

Any ideas of what is wrong here?

Thank you!!!!

29 May 2011, 1:41 PM
#17
ajeh avatar

ajeh

Oba-san

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

Re: Customized shipping modules not working after upgrade

Where have you placed your code?

You test to see if the module should be enabled or not, then go on to test for extra charges ...

Then change the cost to your calculated costs ...

You are also showing the semi-colons on your IF statements:

      if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('manufacturers_id','1') > 0)); {
30 May 2011, 12:45 AM
#18
blackorchidcouture avatar

blackorchidcouture

Zen Follower

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

Re: Customized shipping modules not working after upgrade

Ok, taking the bad semicolons out made the shipping modules show back up in admin, that's good. I also moved the code for testing for the different manufacturers down. I'm very close, if manufacturer 1 is in the cart it is showing the correct shipping cost, but it doesn't add anything if manufacturer 2 is in there. Here's my code in red:

```php
global $cart;

//check if manufacturer 1 and 2 is in cart
$chk_manufacturers_alchemy = $_SESSION['cart']->in_cart_check('manufacturers_id', '1');
$chk_manufacturers_femme_metale = $_SESSION['cart']->in_cart_check('manufacturers_id', '2');

   if ($chk_manufacturers_alchemy > 0) {
      $chk_shipping_charges_one = 5.00;
      } else {
      $chk_shipping_charges_one = 0;
   }

     if ($chk_manufacturers_femme_metale > 0) {
      $chk_shipping_charges_two = 10.00;
      } else {
      $chk_shipping_charges_two = 0;
   }
  $this->quotes = array('id' => $this->code,
                        'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
                        'methods' => array(array('id' => $this->code,
                                                 'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
                                                 'cost' => ($chk_shipping_charges_one + $chk_shipping_charges_two) + MODULE_SHIPPING_FLAT_COST)));

Coffee is on it's way!!
30 May 2011, 12:58 AM
#19
ajeh avatar

ajeh

Oba-san

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

Re: Customized shipping modules not working after upgrade

Are you sure your second Manufacturer is actually manufacturers_id 2 and not some other value?

30 May 2011, 1:20 AM
#20
blackorchidcouture avatar

blackorchidcouture

Zen Follower

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

Re: Customized shipping modules not working after upgrade

I believe it really is, the USPS module is working if I have an item from Alchemy, and item from Femme Metale (manufacturer 2), and a weighted product that triggers the USPS module, all the shipping fees added together are correct.

Under Manufacturers in Admin, I have three listed in this order: Alchemy, Femme Metale, and Other. Is there somewhere else to check the actual number for the manufacturer?