Results 1 to 10 of 2956

Threaded View

  1. #11
    Join Date
    Jun 2014
    Posts
    157
    Plugin Contributions
    0

    Default Re: One-Page Checkout [Support Thread]

    Quote Originally Posted by lat9 View Post
    I can! It's a core-file issue; you'll need to edit /includes/classes/shipping.php's cheapest method:
    Code:
      function cheapest() {
        if (!is_array($this->modules)) return false;
          $rates = array();
    
          foreach($this->modules as $value) {
            $class = substr($value, 0, strrpos($value, '.'));
            if (isset($GLOBALS[$class]) && is_object($GLOBALS[$class]) && $GLOBALS[$class]->enabled) {
              $quotes = isset($GLOBALS[$class]->quotes) ? $GLOBALS[$class]->quotes : null;
              if (empty($quotes['methods'])) {
                continue;
              }
              $size = sizeof($quotes['methods']);
              for ($i=0; $i<$size; $i++) {
                if (isset($quotes['methods'][$i]['cost'])){
                  $rates[] = array('id' => $quotes['id'] . '_' . $quotes['methods'][$i]['id'],
                                   'title' => $quotes['module'] . ' (' . $quotes['methods'][$i]['title'] . ')',
                                   'cost' => $quotes['methods'][$i]['cost'],
                                   'module' => $quotes['id']
                  );
                }
              }
            }
          }
    
          $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') {
                $cheapest = $rates[$i];
              }
            } else {
              if ($rates[$i]['module'] != 'storepickup') {
                $cheapest = $rates[$i];
              }
            }
          }
          $this->notify('NOTIFY_SHIPPING_MODULE_CALCULATE_CHEAPEST', $cheapest, $cheapest, $rates);
          return $cheapest;
      }
    ... and change the highlighted line to read:
    Code:
              if ($size === 1 || $rates[$i]['module'] != 'storepickup') {
    That change enables the storepickup to be selected as the cheapest ... if it's the only shipping method available.

    Hi Cindy,

    If the only shipping method is storepickup AND storepickup contains more than one pickup point, may be with different prices, then $size equals the number of pickup points (not 1).
    Thus, $cheapest is false and shipping options are shown but none will be selected.

    Tested in:
    zc157d
    OPC 2.4.6
    Site has storepickup as the only shipping method but configured with 5 locations and different prices.
    e.g.: Loc_A, 8.5045;Loc_B, 2.5045;Loc_C, 4.5045;Loc_D, 7.5045;Loc_E, 0.5045
    To test, I changed shipping.php, round line 216
    PHP Code:
            } else {
              if (
    $size === || $rates[$i]['module'] != 'storepickup') {
                
    $cheapest $rates[$i];
              } 
    Thus, $size === 5.
    The 5 locations are shown with bullets in the same order and the first bullet is selected (not cheapest!).
    Payment options are shown as well.

    Without my change in shipping.php, the shipping locations are shown in the same order, none populated and no Payments options are shown, need to refresh the screen to get the payment options (or set 'Payment-Block Action on Shipping Change' to 'Refresh' i.s.o 'Update').

    Any suggestions?


    Thanks,

    @jpda
    Last edited by jpda; 24 Oct 2023 at 06:13 PM. Reason: no colour in code block

 

 

Similar Threads

  1. Set number of products displayed per page (support thread)
    By yellow1912 in forum All Other Contributions/Addons
    Replies: 146
    Last Post: 2 Nov 2023, 12:50 AM
  2. v151 Banners In Main Page - Support Thread
    By stevesh in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 18 Sep 2021, 03:36 PM
  3. v151 Site Map/Page Not Found: Combined [Support Thread]
    By lat9 in forum All Other Contributions/Addons
    Replies: 7
    Last Post: 4 Jan 2016, 02:19 PM
  4. v151 PayPal Express Checkout Using NVP 84.0 [Support Thread]
    By lat9 in forum Addon Payment Modules
    Replies: 32
    Last Post: 28 Dec 2015, 04:54 PM
  5. Checkout Amazon Style -- Support Thread
    By CJPinder in forum All Other Contributions/Addons
    Replies: 72
    Last Post: 13 Apr 2011, 08:18 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