Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / USPS Shipping module disappeared after I customized the module

USPS Shipping module disappeared after I customized the module

Views: 2,309

Results 1 to 11 of 11
23 Nov 2011, 7:42 AM
#1
atfzc avatar

atfzc

New Zenner

Join Date:
Nov 2011
Posts:
22
Plugin Contributions:
0

USPS Shipping module disappeared after I customized the module

Hello,

I'm afraid I messed something up. I changed some coding in the usps.php file so that only one of my categories will have the option to ship via usps. This is the coding I changed:

// bof: only show if all Products are from master_categories_id 3
if (!IS_ADMIN_FLAG) {
global $cart;
$chk_category_count = 0;
$chk_category_count += $_SESSION['cart']->in_cart_check('master_categories_id','3');
}
if ($_SESSION['cart']->count_contents() != $chk_category_count) {
$this->enabled = false;
}
// eof: only show if all Products are from master_categories_id 3

It worked and only category 3 has the option to ship via usps. Well when I tested the shopping cart I noticed there were a couple of shipping types that I wanted to disable (media and library). When I went into my shipping admin panel my usps shipping module is gone and I can not edit it. However it does calculate shipping in my cart. One other note is that for some reason I cannot edit any of the other shipping methods in my admin panel. What did I do???

23 Nov 2011, 2:31 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: USPS Shipping module disappeared after I customized the module

Check the directory:
/includes/modules/shipping

and make sure that you do not have a backup copy in there ...

27 Nov 2011, 7:38 AM
#3
atfzc avatar

atfzc

New Zenner

Join Date:
Nov 2011
Posts:
22
Plugin Contributions:
0

Re: USPS Shipping module disappeared after I customized the module

Do you mean do I have two usps php files in the includes/shipping/modules? I only have one in there.

27 Nov 2011, 2:23 PM
#4
ajeh avatar

ajeh

Oba-san

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

Re: USPS Shipping module disappeared after I customized the module

A lot of times this happens if you have something like:
usps.php
usps.php.bak

Do you see any debug logs in the /cache directory?

28 Nov 2011, 7:53 AM
#5
atfzc avatar

atfzc

New Zenner

Join Date:
Nov 2011
Posts:
22
Plugin Contributions:
0

Re: USPS Shipping module disappeared after I customized the module

I don't have the .bak file you mentioned, but I did find this debug error.

[23-Nov-2011 08:00:16] PHP Fatal error: Call to a member function count_contents() on a non-object in C:\xampp\htdocs\zen\includes\modules\shipping\usps.php on line 83

Here is what Line 83 and 84 looks like:

if ($_SESSION['cart']->count_contents() != $chk_category_count) {
$this->enabled = false;
}

28 Nov 2011, 7:58 AM
#6
atfzc avatar

atfzc

New Zenner

Join Date:
Nov 2011
Posts:
22
Plugin Contributions:
0

Re: USPS Shipping module disappeared after I customized the module

The name of the debug file looks like it is saying that it is an admin error.

Also line 83 is part of what I change.

28 Nov 2011, 1:58 PM
#7
ajeh avatar

ajeh

Oba-san

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

Re: USPS Shipping module disappeared after I customized the module

Looks like you have customized the shipping module ...

1 you should have an IF around that IF

2 you need to add a:
global $cart;

just above your IF ...

if (!IS_ADMIN_FLAG) {
global $cart;
// your IF here
}

see if that helps ...

2 Dec 2011, 5:35 AM
#8
atfzc avatar

atfzc

New Zenner

Join Date:
Nov 2011
Posts:
22
Plugin Contributions:
0

Re: USPS Shipping module disappeared after I customized the module

Yes this is the section I modified. Here is the the whole thing. I changed what is in red. The //bof to //eof

// disable only when entire cart is free shipping
if (zen_get_shipping_enabled($this->code)) {
$this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
}
// bof: only show if all Products are from master_categories_id 3
if (!IS_ADMIN_FLAG) {
global $cart;
$chk_category_count = 0;
$chk_category_count += $_SESSION['cart']->in_cart_check('master_categories_id','3');
}
if ($_SESSION['cart']->count_contents() != $chk_category_count) {
$this->enabled = false;
}
// eof: only show if all Products are from master_categories_id 3

if ($this->enabled) {

It did what I wanted it to do. The main problem is that when I go into the zen cart admin panel under shipping modules, the usps module has disappeared and I also don't have the ability to edit the other shipping modules. I don't get it, because I didn't modify anything else. Should I just replace the whole includes/modules/shipping file?

2 Dec 2011, 3:07 PM
#9
ajeh avatar

ajeh

Oba-san

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

Re: USPS Shipping module disappeared after I customized the module

You need the IF for the IS_ADMIN_FLAG around all of that:

// bof: only show if all Products are from master_categories_id 3
if (!IS_ADMIN_FLAG) {
  global $cart;
  $chk_category_count = 0;
  $chk_category_count += $_SESSION['cart']->in_cart_check('master_categories_id','3');
  if ($_SESSION['cart']->count_contents() != $chk_category_count) {
    $this->enabled = false;
  }
}
// eof: only show if all Products are from master_categories_id 3
6 Dec 2011, 4:28 AM
#10
atfzc avatar

atfzc

New Zenner

Join Date:
Nov 2011
Posts:
22
Plugin Contributions:
0

Re: USPS Shipping module disappeared after I customized the module

Sorry to be so dense, but am I supposed to put the "if (!IS_ADMIN_FLAG)" coding at the end of that whole thing? Like this?

if ($_SESSION['cart']->count_contents() != $chk_category_count) {
$this->enabled = false;
if (!IS_ADMIN_FLAG)}
// eof: only show if all Products are from master_categories_id 3

I tried this and it didn't work. Again sorry.

6 Dec 2011, 2:17 PM
#11
ajeh avatar

ajeh

Oba-san

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

Re: USPS Shipping module disappeared after I customized the module

You need to add the IF with the IS_ADMIN_FLAG in the same manner that I posted it ...

It needs to surround all of your customization code ...