Forums / Built-in Shipping and Payment Modules / Media rate - seen threads on it but not sure of the solution

Media rate - seen threads on it but not sure of the solution

Locked

Started by mrcastle on 16 Mar 2010, 10:09 PM · Views: 1,720

Results 1 to 16 of 16
This thread is locked. New replies are disabled.
16 Mar 2010, 10:09 PM
#1
mrcastle avatar

mrcastle

Zen Follower

Join Date:
Feb 2010
Posts:
205
Plugin Contributions:
0

Media rate - seen threads on it but not sure of the solution

Hey everyone - I don't think I can fix this problem without php expertise. I want to add a category of used songbooks and I want to offer a media rate---- only for that category.... Problem is, if I add the media rate shipping option, it shows up as an option on every item I'm selling. .. you can bet some guy is going to buy a guitar and then select media rate for shipping. Don't laugh.... I'm a musician and we're all cheap! Anyways, if you can help, it's greatly appreciated.

17 Mar 2010, 3:26 AM
#2
kiddo avatar

kiddo

Totally Zenned

Join Date:
Jul 2006
Location:
SF Bay Area
Posts:
837
Plugin Contributions:
1

Re: Media rate - seen threads on it but not sure of the solution

I've fixed some similar problem (and think I posted it here quite a while ago) about how to check if everything in the cart is in the special category and then show the media mail rate and if an item is found from another category do not show the media mail rate.

I recall it was a pretty simple hack to usps.php

17 Mar 2010, 9:40 PM
#3
mrcastle avatar

mrcastle

Zen Follower

Join Date:
Feb 2010
Posts:
205
Plugin Contributions:
0

Re: Media rate - seen threads on it but not sure of the solution

Thanks for your response. I couldn't find that feed and problem is my knowledge is limited to basic html.

If you (or anyone else reading this) have an idea of where I can go to find the modification it's greatly appreciated.

18 Mar 2010, 3:06 PM
#4
mrcastle avatar

mrcastle

Zen Follower

Join Date:
Feb 2010
Posts:
205
Plugin Contributions:
0

Re: Media rate - seen threads on it but not sure of the solution

hi - you sent me a response about the media rate option I'm trying to add in my shipping. I have pretty limited funds but I'm willing to pay to get this option..... is this something you could help with or do you know some one that can help ?

thanks,
mitch

18 Mar 2010, 5:10 PM
#5
kiddo avatar

kiddo

Totally Zenned

Join Date:
Jul 2006
Location:
SF Bay Area
Posts:
837
Plugin Contributions:
1

Re: Media rate - seen threads on it but not sure of the solution

If I can find it, you can have it for free. It may or may not meet your need. I'll look for it when I'm off work today and post.

Otherwise, someone may pop in and say before then. I recall it was a pretty simple hack.

18 Mar 2010, 8:44 PM
#6
kiddo avatar

kiddo

Totally Zenned

Join Date:
Jul 2006
Location:
SF Bay Area
Posts:
837
Plugin Contributions:
1

Re: Media rate - seen threads on it but not sure of the solution

OK, here is some bs for you.

What it does:

If everything in the cart is from the category where your items that can be shipped via media mail are, the media mail option will be shown.

If there are any items from other categories, the media mail option is NOT shown.

Please make the edits carefully.

To the top of your usps.php file, add:

// Kiddos media mail hack
$show_mediaMail = TRUE; // assume media mail is OK
if (!defined('IS_ADMIN_FLAG'))
	{
	$s_cart = $_SESSION['cart']->get_products();

	// now look for reasons to not use media mail
	foreach($s_cart as $cartitem)
		{
		if($cartitem['category'] != '2') // change "2" to your media mail OK category
			{
			$show_mediaMail = FALSE;
			}
		}
	}

Now find a line that says:

function usps() {
   global $order, $db, $template, $current_page_base

and change it to:

function usps() {
    global $order, $db, $template, $current_page_base, $show_mediaMail;

then find:

    	$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'
      	  );

and REPLACE it with:

```

if($show_mediaMail)
{
$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'
);
} else
{
$this->types = array('EXPRESS' => 'Express Mail',
'FIRST CLASS' => 'First-Class Mail',
'PRIORITY' => 'Priority Mail',
'PARCEL' => 'Parcel Post',
'BPM' => 'Bound Printed Matter',
'LIBRARY' => 'Library'
);
}


Now you will have much joy.

Please make a backup of your usps.php file before editing it.

If you are not so cozy editing, I can send you a copy of usps.php with this plus the current updates and patches.
18 Mar 2010, 8:48 PM
#7
kiddo avatar

kiddo

Totally Zenned

Join Date:
Jul 2006
Location:
SF Bay Area
Posts:
837
Plugin Contributions:
1

Re: Media rate - seen threads on it but not sure of the solution

PS: I forget to mention you must change the line:

if($cartitem['category'] != '2') // change "2" to your media mail OK category

to use whatever category you use for your media mailable items. Change the "2" to whatever is right for you.

20 Mar 2010, 2:29 AM
#8
kiddo avatar

kiddo

Totally Zenned

Join Date:
Jul 2006
Location:
SF Bay Area
Posts:
837
Plugin Contributions:
1

Re: Media rate - seen threads on it but not sure of the solution

So did this work for you?

20 Mar 2010, 4:22 AM
#9
mrcastle avatar

mrcastle

Zen Follower

Join Date:
Feb 2010
Posts:
205
Plugin Contributions:
0

Re: Media rate - seen threads on it but not sure of the solution

Sorry Kiddo... was out of town. Just tried to do your install. Went into shipping and selected media mail as an option in my usps. Went into all of my categories and sure enough media mail is not an option... so far so good. Then I went into my used music books category (#9) and it doesn't offer media mail. Here's the text I altered in the usps.php file. Is it in the correct area at the top of the page ?

<?php // Kiddos media mail hack $show_mediaMail = TRUE; // assume media mail is OK if (!defined('IS_ADMIN_FLAG')) { $s_cart = $_SESSION['cart']->get_products(); // now look for reasons to not use media mail foreach($s_cart as $cartitem) { if($cartitem['category'] != '9') // change "2" to your media mail OK category { $show_mediaMail = FALSE; } } } /** * USPS Module for Zen Cart v1.3.x * RateV3 Updates to: January 4, 2010 * * @package shippingMethod * @copyright Copyright 2003-2009 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license <http://www.zen-cart.com/license/2_0.txt> GNU Public License V2.0 * @version $Id: usps.php 15170 2010-01-04 20:12:08Z ajeh $ */ /** * USPS Shipping Module class * */ class usps extends base { /** * Declare shipping module alias code * * @var string */ var $code; /** * Shipping module display name * * @var string */ var $title; /** * Shipping module display description * * @var string
20 Mar 2010, 4:26 AM
#10
mrcastle avatar

mrcastle

Zen Follower

Join Date:
Feb 2010
Posts:
205
Plugin Contributions:
0

Re: Media rate - seen threads on it but not sure of the solution

kiddo - on the category (#9) that is selected for media mail, it is still showing priority and parcel post as shipping options..... didn't know if that would make a difference figuring it out... mitch

20 Mar 2010, 4:52 AM
#11
kiddo avatar

kiddo

Totally Zenned

Join Date:
Jul 2006
Location:
SF Bay Area
Posts:
837
Plugin Contributions:
1

Re: Media rate - seen threads on it but not sure of the solution

Did you make ALL the edits I listed?

If things are done correctly, the media mail will show up ONLY if EVERYTHING in the cart is from your category 9.

So if you have a few song books, and then add something from another category, a guitar perhaps, the media mail option will NOT show up.

If you want to show ONLY media mail and not your other options when everything in the cart is from category 9, you can edit step 3 above to leave ONLY media mail as an option. If youdo that, make sure to remove the trailing comma after the media mail option.

Is this clear as mud?

20 Mar 2010, 5:22 AM
#12
mrcastle avatar

mrcastle

Zen Follower

Join Date:
Feb 2010
Posts:
205
Plugin Contributions:
0

Re: Media rate - seen threads on it but not sure of the solution

haha - I've been in the mud since I started with this cart but I'm enjoying it.

Yes, I double checked all the mod's and they are per your spec's. I'm using category 9 (song books) for the media rate and have attached a picture of that.

I go into my cart, select the book I have listed in the song book category (only one in there) and then select the "estimate shipping" button. Only options are priority & parcel post.

I know your mod is working because media mail does not show up in "estimate shipping" for any item and it did on everything before. Check out my picture... I'm assuming that #9 is the category ok item ?

20 Mar 2010, 5:40 PM
#13
kiddo avatar

kiddo

Totally Zenned

Join Date:
Jul 2006
Location:
SF Bay Area
Posts:
837
Plugin Contributions:
1

Re: Media rate - seen threads on it but not sure of the solution

Tell me this. Put the one item from category 9 into your shopping cart. Nothing else, just that one item, and tell me if the media mail option shows.

If it does not, you can email me your usps.php file and I'll see what is wrong and send it back to you.

21 Mar 2010, 5:12 AM
#14
mrcastle avatar

mrcastle

Zen Follower

Join Date:
Feb 2010
Posts:
205
Plugin Contributions:
0

Re: Media rate - seen threads on it but not sure of the solution

That is correct. When I put only item #9 in the cart, priority mail and parcel post are the two available shipping options. Ok, I'm attaching my usps.php file zipped ... let's take a looksie and see what I did wrong.

21 Mar 2010, 7:14 PM
#15
kiddo avatar

kiddo

Totally Zenned

Join Date:
Jul 2006
Location:
SF Bay Area
Posts:
837
Plugin Contributions:
1

Re: Media rate - seen threads on it but not sure of the solution

OK, here is modified file for you (and anyone else who wants it)

This is the usps.php with the media mail hack AND all the updates described here:
http://www.zen-cart.com/forum/showthread.php?t=144992

including the "B" version of the update AND the 5 digit rounding fix described toward the end of the thread.

You can get the patched file here:

http://www.zen-fu.com/uspsmediamail/usps.zip

Important: follow the directions for the usps upgrade when installing this file. ie: write down ALL your usps settings and then remove the original usps.php file. upload the new one and re-install and configure the usps module.

And make sure to check the category id near the top to set your media mail only category.

Please hack away at it to customize or extend it to meet your needs.

Note: if you are wondering about the IS_ADMIN check, it is to prevent the mod from trying to access the shopping cart data when you are in your admin page. (prevents bad ju-ju)

Kiddo

22 Mar 2010, 4:24 AM
#16
mrcastle avatar

mrcastle

Zen Follower

Join Date:
Feb 2010
Posts:
205
Plugin Contributions:
0

Re: Media rate - seen threads on it but not sure of the solution

thanks for the great effort kiddo but it's still the same... I completely uninstalled the usps module, copied over your usps.php file and and reinstalled it again just to be sure but it's the same results. I double checked the usps.php file and item #9 is selected for the media rate. All it shows is priority mail and parcel post. As I said, I know your mod is partially working because media rate does not show on any of the items outside of #9.

Hey, it's fine if we just put this on the back-burner...