Results 1 to 6 of 6
  1. #1
    Join Date
    May 2004
    Location
    UK
    Posts
    478
    Plugin Contributions
    0

    Default Select table shipping method as default - freedelivery is being set maybe as cheapest

    Hi

    I have found a number of great posts but none seem to be working out for me

    Basically I have 4 shipping modules

    FlatClone
    FreeSchool (like freedelivery)
    storepickup
    table

    Now for some reason its always defaulting to the "free school delivery" option - which is ONLY available to certain people - I did think that it was triggering the "cheapest" option but I have changed the code in

    classes/shipping

    Code:
          $cheapest = false;
          $size = sizeof($rates);
          for ($i=0; $i<$size; $i++) {
            if (is_array($cheapest)) {
              // never quote storepickup as lowest - needs to be configured in shipping module
    ##          if ($rates[$i]['cost'] < $cheapest['cost'] and $rates[$i]['module'] != 'storepickup') {
              if (($rates[$i]['cost'] < $cheapest['cost'] and ($rates[$i]['module'] != 'storepickup' && $rates[$i]['module'] != 'flatClone' && $rates[$i]['module'] != 'freeschool' || $size == 1))) { 
                $cheapest = $rates[$i];
              }
            } else {
    ##          if ($rates[$i]['module'] != 'storepickup') {
              if ($rates[$i]['module'] != 'storepickup' && $rates[$i]['module'] != 'flatClone' && $rates[$i]['module'] != 'freeschool' || $size == 1) {
                $cheapest = $rates[$i];
              }
            }
          }
          $this->notify('NOTIFY_SHIPPING_MODULE_CALCULATE_CHEAPEST', $cheapest);
          return $cheapest;
        }
      }
    }
    (as seen in this thread https://www.zen-cart.com/showthread....fault+cheapest)

    but that doesn't seem to do anything - so I am wondering if its NOT looking for cheapest....

    I also looked at this thread (https://www.zen-cart.com/showthread....select+default) but as I have more than 1 that didn't help

    Any thoughts on where else to try?

    Basically I wanted it to - by default - select the TABLE rate shipping method none of the others?

    Any pointers would be great thank you
    Sarah

  2. #2
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Select table shipping method as default - freedelivery is being set maybe as chea

    Quote Originally Posted by SarahL View Post
    Hi

    I have found a number of great posts but none seem to be working out for me

    Basically I have 4 shipping modules

    FlatClone
    FreeSchool (like freedelivery)
    storepickup
    table

    Now for some reason its always defaulting to the "free school delivery" option - which is ONLY available to certain people - I did think that it was triggering the "cheapest" option but I have changed the code in

    classes/shipping

    Code:
          $cheapest = false;
          $size = sizeof($rates);
          for ($i=0; $i<$size; $i++) {
            if (is_array($cheapest)) {
              // never quote storepickup as lowest - needs to be configured in shipping module
    ##          if ($rates[$i]['cost'] < $cheapest['cost'] and $rates[$i]['module'] != 'storepickup') {
              if (($rates[$i]['cost'] < $cheapest['cost'] and ($rates[$i]['module'] != 'storepickup' && $rates[$i]['module'] != 'flatClone' && $rates[$i]['module'] != 'freeschool' || $size == 1))) { 
                $cheapest = $rates[$i];
              }
            } else {
    ##          if ($rates[$i]['module'] != 'storepickup') {
              if ($rates[$i]['module'] != 'storepickup' && $rates[$i]['module'] != 'flatClone' && $rates[$i]['module'] != 'freeschool' || $size == 1) {
                $cheapest = $rates[$i];
              }
            }
          }
          $this->notify('NOTIFY_SHIPPING_MODULE_CALCULATE_CHEAPEST', $cheapest);
          return $cheapest;
        }
      }
    }
    (as seen in this thread https://www.zen-cart.com/showthread....fault+cheapest)

    but that doesn't seem to do anything - so I am wondering if its NOT looking for cheapest....

    I also looked at this thread (https://www.zen-cart.com/showthread....select+default) but as I have more than 1 that didn't help

    Any thoughts on where else to try?

    Basically I wanted it to - by default - select the TABLE rate shipping method none of the others?

    Any pointers would be great thank you
    Sarah
    Double check the capitalization of your freeschool module, that you have properly cloned the module, and that in sections of the code similar to below that the appropriate constant value(s) are being considered. I show below the first few lines of the quote function from the freeshipper module with the constant modified from ..._FREESHIPPER_... to ..._FREESCHOOL_... The value of the constant is the value you should be using in your above code...

    Code:
    function quote($method = '') {
      global $order;
      $this->quotes = array('id' => $this->code,
      'module' => MODULE_SHIPPING_FREESCHOOL_TEXT_TITLE
    With regards to "having more than one module" the issue identified in the other thread had to do with, although there are several shipping methods identified in the admin, the results returned based on the cart totals was a single method and that method was not being selected... It could happen to any cart which was why DrByte and Ajeh were working towards a common response not necessarily a response for a single case... Still a good idea to apply the provided fix (at least now that it has been found and fixed will prevent a similar issue in the future, but not necessarily correct the issue above.)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    May 2004
    Location
    UK
    Posts
    478
    Plugin Contributions
    0

    Default Re: Select table shipping method as default - freedelivery is being set maybe as chea

    Hi mc12345678 thank you - I am a little confused on your reply (the freeschool module is cloned from the storepickup module <- just for info as I incorrectly stated earlier)

    So I have

    Code:
      function __construct() {
        $this->code = 'freeschool';
        $this->title = MODULE_SHIPPING_FREESCHOOL_TEXT_TITLE;
        $this->description = MODULE_SHIPPING_FREESCHOOL_TEXT_DESCRIPTION;
    at the start of the module

    based on your reply - how I read it - was that I would use "FREESCHOOL" in the class/shipping.php file instead of "freeschool"? Is that right? I have tried both versions and neither wants to play for some reason

    a puzzle (alleycatz [dot] co [dot] uk if it helps )

    And thanks I don't think I twigged that the "single option" was a fix worth using but yes you are quite right on that! I was a bit too focused on my issue!

    Sarah

  4. #4
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Select table shipping method as default - freedelivery is being set maybe as chea

    Quote Originally Posted by SarahL View Post
    Hi mc12345678 thank you - I am a little confused on your reply (the freeschool module is cloned from the storepickup module <- just for info as I incorrectly stated earlier)

    So I have

    Code:
      function __construct() {
        $this->code = 'freeschool';
        $this->title = MODULE_SHIPPING_FREESCHOOL_TEXT_TITLE;
        $this->description = MODULE_SHIPPING_FREESCHOOL_TEXT_DESCRIPTION;
    at the start of the module

    based on your reply - how I read it - was that I would use "FREESCHOOL" in the class/shipping.php file instead of "freeschool"? Is that right? I have tried both versions and neither wants to play for some reason

    a puzzle (alleycatz [dot] co [dot] uk if it helps )

    And thanks I don't think I twigged that the "single option" was a fix worth using but yes you are quite right on that! I was a bit too focused on my issue!

    Sarah
    Well, regardless of the module selected to use for cloning, there is a similar process used and the modules provide similar "fields" by which to perform tests/populate.

    The code above that is looking for the cheapest shipping module, uses the format: $rates[$i]['module'] to look at the value of 'module' for the rate that comes back...

    In your case, you want to exclude a particular 'module' that has been defined in one of the shipping modules...

    The 'module' value when looking getting a rate is assigned in the quote() function... All shipping modules are expected to have a function that would start like the below in the code:

    Code:
    function quote($method = '')
    Within that function is usually an assignment such as this: (In fact this is copied from the storepickup default module)
    Code:
    $this->quotes = array('id' => $this->code,
    'module' => MODULE_SHIPPING_STOREPICKUP_TEXT_TITLE,
    'methods' => $this->methodsList);
    Where MODULE_SHIPPING_STOREPICKUP_TEXT_TITLE is specifically defined in the includes/YOUR_LANGUAGE/modules/storepickup.php

    but could/should be overridden to the below *if* it is going to be modified:
    includes/YOUR_LANGUAGE/modules/YOUR_TEMPLATE/storepickup.php

    But that define in your overridden shipping module should be modified to:
    MODULE_SHIPPING_FREESCHOOL_TEXT_TITLE

    And your new module:
    includes/YOUR_LANGUAGE/modules/freeschool.php

    And the other aspects of the module renamed as identified in:
    http://www.zen-cart.com/forum/showth...216#post149531
    With a FAQ regarding the "creation" of a cloned shipping module at: https://www.zen-cart.com/content.php...hipping-module

    First things first: the includes/modules/shipping/freeschool.php file and its equivalent includes/languages/english/modules/shipping/freeschool.php file should be generated/modified to provide the clone of the respective "look-a-like" shipping module. It seems that part of that has happened; however, the originally posted code does not evaluate out the freeschool module which means to me that something has not been properly "installed"/modified...

    So, I provided some background on a specific part of the file that is used to "bypass" the module when obtaining the cheapest quote.

    Perhaps easiest to help would be to post the shipping module and its associated language file either as a zip file or between the code tags created by pressing the # symbol in the message box toolbar...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    May 2004
    Location
    UK
    Posts
    478
    Plugin Contributions
    0

    Default Re: Select table shipping method as default - freedelivery is being set maybe as chea

    Ok so I realised that I needed to login/logout in between CLASS/SHIPPING changes - so it is now working using this! thank you for the help

    Code:
          $cheapest = false;
          $size = sizeof($rates);
          for ($i=0; $i<$size; $i++) {
            if (is_array($cheapest)) {
              // never quote storepickup as lowest - needs to be configured in shipping module
              if (($rates[$i]['cost'] < $cheapest['cost'] and ($rates[$i]['module'] != 'storepickup' && $rates[$i]['module'] != 'flatClone' && $rates[$i]['module'] != 'freeschool' || $size == 1))) { 
                $cheapest = $rates[$i];
              }
            } else {
              if ($rates[$i]['module'] != 'storepickup' && $rates[$i]['module'] != 'flatClone' && $rates[$i]['module'] != 'freeschool' || $size == 1) {
               $cheapest = $rates[$i];
              }
            }
          }
          $this->notify('NOTIFY_SHIPPING_MODULE_CALCULATE_CHEAPEST', $cheapest);
          return $cheapest;
        }
      }
    }

  6. #6
    Join Date
    May 2004
    Location
    UK
    Posts
    478
    Plugin Contributions
    0

    Default Re: Select table shipping method as default - freedelivery is being set maybe as chea

    our posts crossed! Sorry I didn't realise that you were saying that it was not working because I had not cloned the shipping module correctly :) Sorry I didn't get that from your post - but I am happy now as it was working just needed a login / logout before I saw it! But yes cloning I agree has to be done right

 

 

Similar Threads

  1. v151 Paypal Express default select the cheapest method regardless the customers' selection
    By kagaroo in forum Built-in Shipping and Payment Modules
    Replies: 3
    Last Post: 18 Nov 2013, 08:45 AM
  2. Set default selected shipping method
    By DigitalShadow in forum General Questions
    Replies: 9
    Last Post: 31 Oct 2013, 03:24 AM
  3. Need to set default shipping method to FedExGround
    By rgshearer in forum Built-in Shipping and Payment Modules
    Replies: 4
    Last Post: 14 Apr 2011, 04:15 PM
  4. Set shipping method to Default?
    By Chariotz in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 5 Dec 2009, 03:25 AM
  5. Set a Default Shipping Method in Checkout?
    By magpie in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 29 Aug 2009, 05: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