Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17
  1. #11
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,023
    Plugin Contributions
    32

    Default Re: Hide Available Shipping Methods table until Shipping Estimator runs

    Quote Originally Posted by Beagle View Post
    Fair enough. Did not mean to suggest that this change would fix a conflict with a shipping module.



    Note the ! - checks for customer NOT logged in.

    The logic of the shipping estimator is something like:

    IF (customer is logged in) THEN
    Use customer's address information for shipping estimate
    ELSE
    Present form to collect Country, State, Zip and use this for shipping estimate
    END IF

    But if the customer is logged in, the variables set by the form under ELSE are not set. Therefore the display of the shipping estimate is not presented, since the modification discussed here disables the display if any of the variables are not set. My additional condition ignores all the other conditions if the customer is logged in.

    I present this should someone else have the same display issue - as far as I can tell, the original code cannot work if the customer is logged in.
    Read your ealier post a bit too fast.. So I stand corrected.. You are right the original code probably never worked when a customer was logged in.. (admittedly I never tested this when I first used it..) so in the name of clarity gonna post the FULL change (makes it easier for folks following this if they don't have to piece together the change)

    This is a replacement for the /includes/templates/YOUR_TEMPLATE/templates/tpl_modules_shipping_estimator.php. There are two areas that were changed, just look for the //-bof and //-eof comments.

    Code:
    <?php
          }
        }
        if($_SESSION['cart']->get_content_type() == 'virtual'){
    ?>
    <?php echo CART_SHIPPING_METHOD_FREE_TEXT .  ' ' . CART_SHIPPING_METHOD_ALL_DOWNLOADS; ?>
    <?php
        }elseif ($free_shipping==1) {
    ?>
    <?php echo sprintf(FREE_SHIPPING_DESCRIPTION, $currencies->format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)); ?>
    <?php
        }else{
    //-bof-No display until country/state/zip are entered (1 of 2)
          if (($selected_country == 0 || ($selectedState == '' && $state_zone_id == 0) || $zip_code == '')  && (!$_SESSION['customer_id'])) {
            if (!defined(TEXT_ENTER_ALL_VALUES)) define ('TEXT_ENTER_ALL_VALUES', 'Please select your country, state and zipcode so that we can can retrieve an accurate shipping estimate.');
            echo '<p>' . TEXT_ENTER_ALL_VALUES . '</p>';
          } else {
    //-eof-No display until country/state/zip are entered (1 of 2)
    ?>
    <table width="100%" border="1" cellpadding="2" cellspacing ="2">
    <?php if ($_SESSION['customer_id'] < 1 ){ ?>
        <tr>
          <td colspan="2" class="seDisplayedAddressLabel">
            <?php echo CART_SHIPPING_QUOTE_CRITERIA; ?><br />
            <?php echo '<span class="seDisplayedAddressInfo">' . zen_get_zone_name($selected_country, $state_zone_id, '') . ($selectedState != '' ? ' ' . $selectedState : '') . ' ' . $order->delivery['postcode'] . ' ' . zen_get_country_name($order->delivery['country_id']) . '</span>'; ?>
          </td>
        </tr>
    <?php } ?>
         <tr>
           <th scope="col" id="seProductsHeading"><?php echo CART_SHIPPING_METHOD_TEXT; ?></th>
           <th scope="col" id="seTotalHeading"><?php echo CART_SHIPPING_METHOD_RATES; ?></th>
         </tr>
    <?php
          for ($i=0, $n=sizeof($quotes); $i<$n; $i++) {
            if(sizeof($quotes[$i]['methods'])==1){
              // simple shipping method
              $thisquoteid = $quotes[$i]['id'].'_'.$quotes[$i]['methods'][0]['id'];
    ?>
         <tr class="<?php echo $extra; ?>">
    <?php
              if($quotes[$i]['error']){
    ?>
             <td colspan="2"><?php echo $quotes[$i]['module']; ?>&nbsp;(<?php echo $quotes[$i]['error']; ?>)</td>
           </tr>
    <?php
              }else{
                if($selected_shipping['id'] == $thisquoteid){
    ?>
             <td class="bold"><?php echo $quotes[$i]['module']; ?>&nbsp;(<?php echo $quotes[$i]['methods'][0]['title']; ?>)</td>
             <td class="cartTotalDisplay bold"><?php echo $currencies->format(zen_add_tax($quotes[$i]['methods'][0]['cost'], $quotes[$i]['tax'])); ?></td>
           </tr>
    <?php
                }else{
    ?>
              <td><?php echo $quotes[$i]['module']; ?>&nbsp;(<?php echo $quotes[$i]['methods'][0]['title']; ?>)</td>
              <td class="cartTotalDisplay"><?php echo $currencies->format(zen_add_tax($quotes[$i]['methods'][0]['cost'], $quotes[$i]['tax'])); ?></td>
           </tr>
    <?php
                }
              }
            } else {
              // shipping method with sub methods (multipickup)
              for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) {
                $thisquoteid = $quotes[$i]['id'].'_'.$quotes[$i]['methods'][$j]['id'];
    ?>
        <tr class="<?php echo $extra; ?>">
    <?php
                if($quotes[$i]['error']){
    ?>
             <td colspan="2"><?php echo $quotes[$i]['module']; ?>&nbsp;(<?php echo $quotes[$i]['error']; ?>)</td>
           </tr>
    <?php
                }else{
                  if($selected_shipping['id'] == $thisquoteid){
    ?>
             <td class="bold"><?php echo $quotes[$i]['module']; ?>&nbsp;(<?php echo $quotes[$i]['methods'][$j]['title']; ?>)</td>
             <td class="cartTotalDisplay bold"><?php echo $currencies->format(zen_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax'])); ?></td>
           </tr>
    <?php
                  }else{
    ?>
            <td><?php echo $quotes[$i]['module']; ?>&nbsp;(<?php echo $quotes[$i]['methods'][$j]['title']; ?>)</td>
            <td class="cartTotalDisplay"><?php echo $currencies->format(zen_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax'])); ?></td>
          </tr>
    <?php
                  }
                }
              }
            }
          }
    ?>
    </table>
    <?php
       }
    //-bof-No display until country/state/zip are entered (2 of 2)
       }
    //-eof-No display until country/state/zip are entered (2 of 2)
      }
    ?>
    </form>
    </div>
    My Site - Zen Cart & WordPress integration specialist
    I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

  2. #12
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: Hide Available Shipping Methods table until Shipping Estimator runs

    Quote Originally Posted by DivaVocals View Post
    Read your ealier post a bit too fast.. So I stand corrected.. You are right the original code probably never worked when a customer was logged in.. (admittedly I never tested this when I first used it..) so in the name of clarity gonna post the FULL change (makes it easier for folks following this if they don't have to piece together the change)

    This is a replacement for the /includes/templates/YOUR_TEMPLATE/templates/tpl_modules_shipping_estimator.php. There are two areas that were changed, just look for the //-bof and //-eof comments.

    Code:
    <?php
          }
        }
        if($_SESSION['cart']->get_content_type() == 'virtual'){
    ?>
    <?php echo CART_SHIPPING_METHOD_FREE_TEXT .  ' ' . CART_SHIPPING_METHOD_ALL_DOWNLOADS; ?>
    <?php
        }elseif ($free_shipping==1) {
    ?>
    <?php echo sprintf(FREE_SHIPPING_DESCRIPTION, $currencies->format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)); ?>
    <?php
        }else{
    //-REMOVE -- REMOVE -- REMOVE -- REMOVE --       
    if (($selected_country == 0 || ($selectedState == '' && $state_zone_id == 0) || $zip_code == '')  && (!$_SESSION['customer_id'])) {
            if (!defined(TEXT_ENTER_ALL_VALUES)) define ('TEXT_ENTER_ALL_VALUES', 'Please select your country, state and zipcode so that we can can retrieve an accurate shipping estimate.');
            echo '<p>' . TEXT_ENTER_ALL_VALUES . '</p>';
          } else {
    //-REMOVE -- REMOVE -- REMOVE -- REMOVE --
    ?>
    //-BOF REMOVE TABLE TILL ZIP CODE ENTERED OR CUSTOMER SESSION EXISTS
    <?php if ($_SESSION['customer_id'] < '1' and !empty($order->delivery['postcode']) or $_SESSION['customer_id']){ ?>
    //-EOF REMOVE TABLE TILL ZIP CODE ENTERED OR CUSTOMER SESSION EXISTS
    <table width="100%" border="1" cellpadding="2" cellspacing ="2">
    //-MOVE ABOVE <HTML TABLE> AND CHANGE TO RED CODE
    <?php if ($_SESSION['customer_id'] < 1 ){ ?>
    //-MOVE ABOVE <HTML TABLE> AND CHANGE TO RED CODE
        <tr>
          <td colspan="2" class="seDisplayedAddressLabel">
            <?php echo CART_SHIPPING_QUOTE_CRITERIA; ?><br />
            <?php echo '<span class="seDisplayedAddressInfo">' . zen_get_zone_name($selected_country, $state_zone_id, '') . ($selectedState != '' ? ' ' . $selectedState : '') . ' ' . $order->delivery['postcode'] . ' ' . zen_get_country_name($order->delivery['country_id']) . '</span>'; ?>
          </td>
        </tr>
    //-REMOVE -- REMOVE -- REMOVE -- REMOVE --
    <?php } ?>
    //-REMOVE -- REMOVE -- REMOVE -- REMOVE --
         <tr>
           <th scope="col" id="seProductsHeading"><?php echo CART_SHIPPING_METHOD_TEXT; ?></th>
           <th scope="col" id="seTotalHeading"><?php echo CART_SHIPPING_METHOD_RATES; ?></th>
         </tr>
    <?php
          for ($i=0, $n=sizeof($quotes); $i<$n; $i++) {
            if(sizeof($quotes[$i]['methods'])==1){
              // simple shipping method
              $thisquoteid = $quotes[$i]['id'].'_'.$quotes[$i]['methods'][0]['id'];
    ?>
         <tr class="<?php echo $extra; ?>">
    <?php
              if($quotes[$i]['error']){
    ?>
             <td colspan="2"><?php echo $quotes[$i]['module']; ?>&nbsp;(<?php echo $quotes[$i]['error']; ?>)</td>
           </tr>
    <?php
              }else{
                if($selected_shipping['id'] == $thisquoteid){
    ?>
             <td class="bold"><?php echo $quotes[$i]['module']; ?>&nbsp;(<?php echo $quotes[$i]['methods'][0]['title']; ?>)</td>
             <td class="cartTotalDisplay bold"><?php echo $currencies->format(zen_add_tax($quotes[$i]['methods'][0]['cost'], $quotes[$i]['tax'])); ?></td>
           </tr>
    <?php
                }else{
    ?>
              <td><?php echo $quotes[$i]['module']; ?>&nbsp;(<?php echo $quotes[$i]['methods'][0]['title']; ?>)</td>
              <td class="cartTotalDisplay"><?php echo $currencies->format(zen_add_tax($quotes[$i]['methods'][0]['cost'], $quotes[$i]['tax'])); ?></td>
           </tr>
    <?php
                }
              }
            } else {
              // shipping method with sub methods (multipickup)
              for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) {
                $thisquoteid = $quotes[$i]['id'].'_'.$quotes[$i]['methods'][$j]['id'];
    ?>
        <tr class="<?php echo $extra; ?>">
    <?php
                if($quotes[$i]['error']){
    ?>
             <td colspan="2"><?php echo $quotes[$i]['module']; ?>&nbsp;(<?php echo $quotes[$i]['error']; ?>)</td>
           </tr>
    <?php
                }else{
                  if($selected_shipping['id'] == $thisquoteid){
    ?>
             <td class="bold"><?php echo $quotes[$i]['module']; ?>&nbsp;(<?php echo $quotes[$i]['methods'][$j]['title']; ?>)</td>
             <td class="cartTotalDisplay bold"><?php echo $currencies->format(zen_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax'])); ?></td>
           </tr>
    <?php
                  }else{
    ?>
            <td><?php echo $quotes[$i]['module']; ?>&nbsp;(<?php echo $quotes[$i]['methods'][$j]['title']; ?>)</td>
            <td class="cartTotalDisplay"><?php echo $currencies->format(zen_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax'])); ?></td>
          </tr>
    <?php
                  }
                }
              }
            }
          }
    ?>
    </table>
    <?php
       }
    //-bof-No display until country/state/zip are entered (2 of 2)  KEEP 
       }
    //-eof-No display until country/state/zip are entered (2 of 2)     KEEP
      }
    ?>
    </form>
    </div>
    Hope this helps and what you are looking to do.
    Website - Github. Like the ZCA Bootstrap 4 Template? Donations Welcome. Bootstrap Plugins?

  3. #13
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,023
    Plugin Contributions
    32

    Default Re: Hide Available Shipping Methods table until Shipping Estimator runs

    Quote Originally Posted by rbarbour View Post
    Hope this helps and what you are looking to do.
    Honestly speaking what you posted isn't clear all.. the blue and red coloring confuses rather than clarifies things.. I tried your code and it doesn't work, and breaks a few things.. The code I posted (lat9's original code + the changes Beagle made) does achieve the original objective "Hide Available Shipping Methods table until Shipping Estimator runs", and now it works whether you are logged in or not.. Plus it has the added bonus of providing a nice on-screen message to remind the site visitor to enter the required info needed to obtain a shipping estimate..
    My Site - Zen Cart & WordPress integration specialist
    I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

  4. #14
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: Hide Available Shipping Methods table until Shipping Estimator runs

    Quote Originally Posted by DivaVocals View Post
    Honestly speaking what you posted isn't clear all.. the blue and red coloring confuses rather than clarifies things.. I tried your code and it doesn't work, and breaks a few things..
    "Hit" Post Quick Reply prematurely, to late to edit and I figured I would get a response anyways.

    Quote Originally Posted by DivaVocals View Post
    The code I posted (lat9's original code + the changes Beagle made) does achieve the original objective "Hide Available Shipping Methods table until Shipping Estimator runs", and now it works whether you are logged in or not.. Plus it has the added bonus of providing a nice on-screen message to remind the site visitor to enter the required info needed to obtain a shipping estimate..
    Yes it does, maybe I will read entire threads before I post. lol
    Website - Github. Like the ZCA Bootstrap 4 Template? Donations Welcome. Bootstrap Plugins?

  5. #15
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,023
    Plugin Contributions
    32

    Default Re: Hide Available Shipping Methods table until Shipping Estimator runs

    Quote Originally Posted by rbarbour View Post
    "Hit" Post Quick Reply prematurely, to late to edit and I figured I would get a response anyways.



    Yes it does, maybe I will read entire threads before I post. lol
    Yeah.. well I did the same thing earlier in this thread.. It's all good!!
    My Site - Zen Cart & WordPress integration specialist
    I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

  6. #16
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,023
    Plugin Contributions
    32

    Default Re: Hide Available Shipping Methods table until Shipping Estimator runs

    This snippet can also be found here:
    https://gist.github.com/DivaVocals/8303bef759f9648cbf86
    My Site - Zen Cart & WordPress integration specialist
    I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

  7. #17
    Join Date
    Jan 2013
    Posts
    811
    Plugin Contributions
    0

    Default Re: Hide Available Shipping Methods table until Shipping Estimator runs

    How would i add this to zen 1.56c shipping estimator file

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 30
    Last Post: 30 Dec 2013, 08:20 PM
  2. hide other shipping methods with free shipping
    By thenax in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 10 Nov 2009, 09:46 PM
  3. Hide the shipping estimator if only free shipping?
    By westcoastfavors in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 22 Dec 2007, 06:27 AM
  4. USPS - No shipping methods available
    By DeV0id in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 12 May 2007, 04:29 AM
  5. Shipping Estimator Sort Shipping Methods
    By sitehatchery in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 15 Apr 2007, 05:34 AM

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