Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2016
    Posts
    56
    Plugin Contributions
    0

    Default Need to prevent ZC from selecting the cheapest shipping method

    On ZC 1.5.8a, is there a way to prevent it selecting the cheapest shipping method during checkout?

    I have 3 shipping methods for orders inside Australia, in order from cheapest to dearest:
    1) $5 flat rate for small items that will fit in a 16mm thick flat box
    2) Regular parcel post
    3) Express post

    So, if I enable the express paypal checkout button which appears on the first checkout page, customers click that and it automatically selects the cheapest $5 option regardless of whether that method is appropriate or not. I have the option to select the cheapest method turned off in the paypal module, but that doesn't help as the cart itself selects the cheapest method by default.

    I have read a few threads here regarding this, but they only seem to apply to older versions of ZC, such as https://www.zen-cart.com/showthread....hipping-method

    So, is there a way to select a specific shipping method by default? Seems like it would be a good addition to admin to have that option.

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,498
    Plugin Contributions
    88

    Default Re: Need to prevent ZC from selecting the cheapest shipping method

    Did you try DrByte's suggestion to change the paypalwpp module's "Select Cheapest Shipping Automatically" setting? https://www.zen-cart.com/showthread....976#post518976

  3. #3
    Join Date
    Jul 2016
    Posts
    56
    Plugin Contributions
    0

    Default Re: Need to prevent ZC from selecting the cheapest shipping method

    Thanks, yes, mentioned that in my post, it makes no difference because the cart selects it anyway and passes that to paypal.

  4. #4
    Join Date
    Apr 2009
    Posts
    418
    Plugin Contributions
    2

    Default Re: Need to prevent ZC from selecting the cheapest shipping method

    Not sure what you want to achieve. If it is to exclude a shipping method you If you look at includes/classes/shipping.php and look at the function cheapest you will see that you can use the notifier 'NOTIFY_SHIPPING_EXCLUDE_FROM_CHEAPEST' to exclude shipping models. You will have to write code to do this, see https://docs.zen-cart.com/dev/code/notifiers/.
    Additionally if you want to change what is selected as the cheapest the notifier 'NOTIFY_SHIPPING_MODULE_CALCULATE_CHEAPEST' is also available.
    Mark Brittain
    http:\\innerlightcrystals.co.uk\sales\

  5. #5
    Join Date
    Jul 2016
    Posts
    56
    Plugin Contributions
    0

    Default Re: Need to prevent ZC from selecting the cheapest shipping method

    No, don't want to exclude the shipping method, I just want to have the method default to something other than the cheapest, so that when I turn on the paypal button in checkout, it doesn't ship every order using the cheap method rather than the appropriate method.

    A few people have asked this previously, but the responses I could find in the forums seemed to apply to older versions of ZC, I applied one I found for 1.5.7 (not sure of the thread now though, sorry) and it immediately gave a 500 server error, so I expect this would need to be looked at for 1.5.8.

    I would like to be able to have the quick checkout paypal button active, but can't as the checkout currently works because there's no way to bypass the cheapest shipping option.

    The $5 large letter flat box option is only applicable to certain products in my store, and customers have been pretty good at selecting the correct method so far, but once I turned on the paypal quick checkout button, every order came through with the $5 shipping option even if it contained items that obviously would not fit in 16mm flat box.

    Edit: should state that while I'm happy to update code in the shop, I'm not a coder, so writing/updating shop code is something I'm unable to do safely.

  6. #6
    Join Date
    Apr 2009
    Posts
    418
    Plugin Contributions
    2

    Default Re: Need to prevent ZC from selecting the cheapest shipping method

    You will have to write some code. If you use the notifier 'NOTIFY_SHIPPING_MODULE_CALCULATE_CHEAPEST' you can set the cheapest to anything you want.
    I wrote one to exclude surface mail from being selected as the cheapest.

    includes/classes/observers/cheapest_mail_recalculate.php
    Code:
    <?php
    
    // -----
    // An observer-class to enable recalculation of the minimum postage to exclude options.
    //
    //
    class CheapestMailRecalculate extends base {
    
        public function __construct() {
            $this->attach($this, array(
                'NOTIFY_SHIPPING_MODULE_CALCULATE_CHEAPEST'
            ));
        }
    
        public function update(&$class, $eventID, $cheapestIn, &$cheapestOut, $rates) {
            /*
             * only need to change if royalmail surface (economy) rmsm or book surface bksm
             */
            if (substr($cheapestIn['module'], 0, 4) == 'rmsm' or substr($cheapestIn['module'], 0, 4) == 'bksm') {
                $cheapestOut = false;
                $size = sizeof($rates);
                for ($i = 0; $i < $size; $i++) {
                    if (is_array($cheapestOut)) {
                        /*
                         * already found rate is this one cheaper
                         */
                        if ($rates[$i]['cost'] < $cheapestOut['cost'] and $rates[$i]['module'] != 'storepickup' and substr($rates[$i]['module'], 0, 4) != 'rmsm' and substr($rates[$i]['module'], 0, 4) != 'bksm') {
                            $cheapestOut = $rates[$i];
                        }
                    } else {
                        /*
                         * not found a rate yet set if not storepickup or economy
                         */
                        if ($rates[$i]['module'] != 'storepickup' and substr($rates[$i]['module'], 0, 4) != 'rmsm' and substr($rates[$i]['module'], 0, 4) != 'bksm') {
                            $cheapestOut = $rates[$i];
                        }
                    }
                }
            }
        }
    
    }
    includes/auto_loadres/config.cheapest_mail_recalculate.php
    Code:
    <?php
    $autoLoadConfig[10][] = array('autoType'=>'class',
                                  'loadFile'=>'observers/cheapest_mail_recalculate.php');
    $autoLoadConfig[90][] = array('autoType'=>'classInstantiate',
                                  'className'=>'CheapestMailRecalculate',
                                  'objectName'=>'CheapestMailRecalculate');
    This was written some time ago for 1.3.7 zen cart there are other ways of writing observers now.
    see https://docs.zen-cart.com/dev/code/notifiers/.
    Mark Brittain
    http:\\innerlightcrystals.co.uk\sales\

 

 

Similar Threads

  1. selecting cheapest supplier?
    By DaMixa in forum Managing Customers and Orders
    Replies: 4
    Last Post: 6 Jul 2011, 08:25 AM
  2. Replies: 7
    Last Post: 14 May 2011, 02:46 AM
  3. Free Shipping - Using cheapest method?
    By nohart in forum Built-in Shipping and Payment Modules
    Replies: 10
    Last Post: 29 Apr 2011, 02:17 PM
  4. How to view only the cheapest shipping method?
    By jnascimento in forum General Questions
    Replies: 0
    Last Post: 21 Apr 2010, 03:50 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR