Results 1 to 10 of 12

Hybrid View

  1. #1
    Join Date
    Jan 2008
    Posts
    154
    Plugin Contributions
    0

    Default Re: USPS shipping module...trying to restrict shipping options programmatically

    Quote Originally Posted by barco57 View Post
    Refer to the in-module comments present in /extras/includes/classes/observers/auto.usps_overrides.php
    Thank you for pointing me in the right direction...but could still use some help if possible. Do I add the extra code in the override file, or just use that as a template and add to the usps.php file?

    Second, can you tell me if I'm on the right track with this coding (wherever it ultimately goes)?

    Code:
    if (stripos($p1, 'USPS Ground Advantage') !== false) {
                        $chk_media = 0;
                        $chk_media += $_SESSION['cart']->in_cart_check('products_tax_class_id', '4') > 0;
                        if ($chk_media == $_SESSION['cart']->count_contents()) {
                            $p2 = true;
                        }
                    }
    break;

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,973
    Plugin Contributions
    96

    Default Re: USPS shipping module...trying to restrict shipping options programmatically

    Quote Originally Posted by mcqueeneycoins View Post
    Thank you for pointing me in the right direction...but could still use some help if possible. Do I add the extra code in the override file, or just use that as a template and add to the usps.php file?

    Second, can you tell me if I'm on the right track with this coding (wherever it ultimately goes)?

    Code:
    if (stripos($p1, 'USPS Ground Advantage') !== false) {
                        $chk_media = 0;
                        $chk_media += $_SESSION['cart']->in_cart_check('products_tax_class_id', '4') > 0;
                        if ($chk_media == $_SESSION['cart']->count_contents()) {
                            $p2 = true;
                        }
                    }
    break;
    @barco57 has put you on the right track, you want to make your changed to the auto.usps_overrides.php (which you'll place in the site's /includes/classes/observers sub-directory). That way, once working, it'll keep on working through a base USPS module update.

    I'm a bit confused from your description as to what you're trying to do:

    I'm wanting to disable Ground Advantage for all tax classes except one (tax_class_id = 4).
    Does this mean that Ground Advantage should be disallowed if any product in the cart uses tax_class_id 4 or if all products use that tax-class?

  3. #3
    Join Date
    Jan 2008
    Posts
    154
    Plugin Contributions
    0

    Default Re: USPS shipping module...trying to restrict shipping options programmatically

    Quote Originally Posted by lat9 View Post
    I'm a bit confused from your description as to what you're trying to do:

    Does this mean that Ground Advantage should be disallowed if any product in the cart uses tax_class_id 4 or if all products use that tax-class?
    Thanks, lat9--basically I have 3 or 4 different tax classes, one of which is for supplies. The way I have it set up now is the flat-rate option is available for all products except tax class id 4, which works just fine. It then displays only the USPS module with ground advantage and priority mail options when tax class id 4 is present in the cart.

    But, if the cart has no supplies (no products with tax id 4), it displays flat rate, ground advantage and priority mail. I basically need ground advantage to be disabled in this case and only display flat rate and priority.

    THanks!

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,973
    Plugin Contributions
    96

    Default Re: USPS shipping module...trying to restrict shipping options programmatically

    Quote Originally Posted by mcqueeneycoins View Post
    Thanks, lat9--basically I have 3 or 4 different tax classes, one of which is for supplies. The way I have it set up now is the flat-rate option is available for all products except tax class id 4, which works just fine. It then displays only the USPS module with ground advantage and priority mail options when tax class id 4 is present in the cart.

    But, if the cart has no supplies (no products with tax id 4), it displays flat rate, ground advantage and priority mail. I basically need ground advantage to be disabled in this case and only display flat rate and priority.

    THanks!
    Thanks for the clarification! You can use the following code in that auto-loaded observer:
    Code:
                case 'NOTIFY_USPS_UPDATE_OR_DISALLOW_TYPE':
                    // -----
                    // Disallow "Ground Advantage" if there are no products with a tax_class_id of 4
                    // in the cart.
                    //
                    if (stripos($p1, 'USPS Ground Advantage') !== false) {
                        if ($_SESSION['cart']->in_cart_check('products_tax_class_id', '4') == 0) {
                            $p2 = false;
                        }
                    }
                    break;

  5. #5
    Join Date
    Jan 2008
    Posts
    154
    Plugin Contributions
    0

    Default Re: USPS shipping module...trying to restrict shipping options programmatically

    Quote Originally Posted by lat9 View Post
    Thanks for the clarification! You can use the following code in that auto-loaded observer:
    Code:
                case 'NOTIFY_USPS_UPDATE_OR_DISALLOW_TYPE':
                    // -----
                    // Disallow "Ground Advantage" if there are no products with a tax_class_id of 4
                    // in the cart.
                    //
                    if (stripos($p1, 'USPS Ground Advantage') !== false) {
                        if ($_SESSION['cart']->in_cart_check('products_tax_class_id', '4') == 0) {
                            $p2 = false;
                        }
                    }
                    break;
    Worked like a charm--thank you!

  6. #6
    Join Date
    Jan 2008
    Posts
    154
    Plugin Contributions
    0

    Default Re: USPS shipping module...trying to restrict shipping options programmatically

    @lat9--sorry, quick follow up question. Is there an easy way to change the display name of the shipping service? Right now it shows up as USPS Ground Advantage. Because of how I have my shipping options set up/combined, I'd like for it to just say Ground Advantage. I believe the module is pulling this info direct from USPS and didn't see a language file unless I missed one? Thanks again!

 

 

Similar Threads

  1. v155 Restrict USPS shipping options by product dimensions
    By HeleneWallis in forum Addon Shipping Modules
    Replies: 12
    Last Post: 29 Feb 2020, 03:30 AM
  2. v151 USPS shipping module - no shipping options being displayed
    By TooMuchMUsic in forum Addon Shipping Modules
    Replies: 4
    Last Post: 26 Sep 2015, 04:00 PM
  3. v151 Restrict Specific Items from 1st Class Shipping - USPS Module
    By jstevens in forum Addon Shipping Modules
    Replies: 5
    Last Post: 22 Jun 2014, 03:03 AM
  4. Replies: 16
    Last Post: 31 May 2012, 07:08 PM
  5. Replies: 2
    Last Post: 1 Jul 2009, 11:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg