Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?
Glad that this is working for you now ...
Thanks for the kudos and support we really appreciate it a lot ... coffee and donuts keep the Zen Cart Team humming right along ... :cool:
Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?
I was trying to get the Media Mail restrictions to work as well and added the code per the instructions above.
I am using the latest version Version: 2014-09-07 K5
And instead of using Media MailRM, I had to use Media Mail Parcel
I used the print_r($type_rebuilt);
that linniedarling suggested and it output:
First-Class Mail ParcelMedia Mail ParcelPriority MailTM
So I guess that's what you all were doing and it seems to have worked for me.
I am not that good with PHP at all (took me 2 hours just to get this working)
So if anyone could double check to make sure
Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?
Quote:
Originally Posted by
regjimbob
I was trying to get the Media Mail restrictions to work as well and added the code per the instructions above.
I am using the latest version Version: 2014-09-07 K5
And instead of using Media MailRM, I had to use Media Mail Parcel
I used the print_r($type_rebuilt);
that linniedarling suggested and it output:
First-Class Mail ParcelMedia Mail ParcelPriority MailTM
So I guess that's what you all were doing and it seems to have worked for me.
I am not that good with PHP at all (took me 2 hours just to get this working)
So if anyone could double check to make sure
Yes, the USPS changed the name of Media Mail from Media MailRM to Media Mail Parcel going from the 3/7 to 9/7 implementations.
Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?
Yes, you need to use:
Code:
$type == 'Media Mail Parcel'
USPS renamed it on the September 7, 2014 changes ...
Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?
Dontcha hate when you get interrupted when posting only to find your answer posted 2 minutes before your own ... :cool:
Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?
Tee-hee, it happens to me all the time!
Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?
Hi
I have added this modification to my shop. My media related items are located within sub-categories of the parent category
EX:
books (id 342)
- cookbooks (id 24)
- childrens books (id 52)
- old school books (id 72)
I have 32 sub categories in the books category but that sub category amount will probably increase over time. Is there a way to add the parent category ID 342 in such a way that all its sub categories would be included without having to add the ID for each subcategory manually?
using
$chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','342');
doesn't work so I need to add the sub cat id instead
$chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','24');
$chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','52');
$chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','72');
If it's possible it would be good because I have a feeling a few months from now if I add a new sub cat I will probably forget to edit the usps.php file.
thanks
Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?
You could use this code in RED to count how many products are in the cart for that parent categories_id:
Code:
// see below use of $chk_cart
// eof: example to block USPS Priority MailTM Small Flat Rate Box when anything from master_categories_id 12 or 15 are in the cart
// bof: skip Products in any subcategory for parents_id 3
$subcategories_array = array();
$chk_cat = '3'; // parent categories_id
$chk_cart = 0;
zen_get_subcategories($subcategories_array, $chk_cat);
for ($i=0, $n=sizeof($subcategories_array); $i<$n; $i++ ) {
$chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id', $subcategories_array[$i]);
}
//echo 'USPS products in parent category 3: ' . $chk_cart . '<br>';
// eof: skip Products in any subcategory for parents_id 3
for ($i=0; $i<$PackageSize; $i++) {
Just change the $chk_cat to your parent categories_id 342 and $chk_cart will have the quantity that is in the cart ...
Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?
thank you
ohhh I'm sorry, I forgot that some books are in sub sub cats too. Would that significantly change the code you provided?
For instance
books (id 342)
- cookbooks (id 24)
- childrens books (id 52)
- old school books (id 72)
- crafts and hobbies (id 97)
-- a sub sub cat (id 231)
-- a sub sub cat (id 321)
-- a sub sub cat (id 523)
Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?
If you need to calculate the Products in the Shopping Cart for both a Parent Category and then additional categories, beneath the code that I gave you to calculate the Products from all categories within a parent category, you can add the additional categories you need with:
Code:
$chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id','231');
$chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id','321');
$chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id','523');
to combine the products that match ...