Page 1 of 7 123 ... LastLast
Results 1 to 10 of 70
  1. #1
    Join Date
    Aug 2007
    Posts
    36
    Plugin Contributions
    2

    Default new staticlist shipping module

    Greetings Zenophiles....

    I have a new module to offer to the community, but it has a lingering bug and I'm new to Zen Cart and PHP, so I could use a hand....

    First a description of the module:

    This is a shipping module that lists a configurable number of static options from which a customer may select. The options consist of a description paired with a price. This might be useful, for example, if you make regular deliveries to a specific set of locations such as Farmer's Markets, or if you are involved in fund raisers, each with a specific organizational affiliation, delivery date or location.`

    Now a description of the bug:

    You'll notice that the module seems to work when a customer begins the checkout process: checkout_shipping displays the options, their prices, and all seems right with the world. But then when you move on to the next step of checkout, checkout_payment, the first option in the series, Option 0, is the only one that ever gets listed.

    Any ideas?

    Thanks,
    Rick

    Download here: http://www.zen-cart.com/downloads.php?do=file&id=528

  2. #2
    Join Date
    Aug 2007
    Posts
    36
    Plugin Contributions
    2

    Default Re: new staticlist shipping module

    Hello everyone --

    I could really use a hand here.

    I am trying to develop a simple shipping module, which is very nearly finished, that I believe will be a useful addition to the suite of available shipping modules once it is done. But I need some help to resolve a bug.

    The module supports an arbitrary number of options. Let's call them Option 0, Option 1, Option 2, Option 3 and so on. My problem is that Options 1, 2 or 3 never make it through the checkout process. That is, when a shopper selects Option 1 as the shipping method for their order, Option 0 shows up as their selected shipping method on the next page of checkout. Likewise, if a shopper selects Option 2, or Option 3, they are never recognized. The system always falls back to using Option 0 regardless of the shopper's selection.

    So here is my question: How does the system maintain state with regard to shipping methods? Does a variable need to be set? Is it based on the return value of the quote() function? I'd appreciate any guidance or suggestions for troubleshooting.

    Vital statistics:

    Zen Cart version: 1.3.7.1
    Database Patch Level: 1.3.7.1
    Server OS: Linux 2.6.9-42.ELsmp
    Database: MySQL 5.0.27
    PHP Version: 5.1.4 (Zend: 2.1.0)
    HTTP Server: Apache/2.0.52 (Red Hat) DAV/2 SVN/1.3.2 mod_ssl/2.0.52 OpenSSL/0.9.7a PHP/5.1.4 mod_fastcgi/2.4.2

    Thanks again,
    Rick

  3. #3
    Join Date
    Aug 2007
    Posts
    36
    Plugin Contributions
    2

    Default Re: new staticlist shipping module

    Hello everyone,

    The bug basically amounted to this: When the system calls a shipping module's quote() function with a non-null value for $method, it does not want a fully populated array of shipping methods; rather, it is only interested in the value of $this->quotes['methods'][0], that is, it is only interested in the value of the first element of the methods array. Under this condition, $method should be used to determine which of the available options is to be reported back via $this->quotes['methods'][0] and the rest of the methods array (namely $this->quotes['methods'][1] and $this->quotes['methods'][2] and so on) is irrelevant.

    By the way, for those of you learning PHP or trying to figure out the internals of Zen Cart, I found liberal use of PHP's error_log() and print_r() functions useful. For example:

    error_log( 'staticlist(): $this: ' . print_r($this,TRUE) . "\n", 3, "/tmp/debug.log");

    Regards,
    Rick

  4. #4
    Join Date
    Apr 2005
    Location
    Spokane, Washington
    Posts
    372
    Plugin Contributions
    0

    Default Re: new staticlist shipping module

    I've installed and configured it and it works fine for me.

    Jacque
    http://www.freshabundance.com

    Just knowledgeable enough to be dangerous.

  5. #5
    Join Date
    Apr 2005
    Location
    Spokane, Washington
    Posts
    372
    Plugin Contributions
    0

    Default Re: new staticlist shipping module

    Here's a question...

    How can I hide/remove the $0.00 (shipping fee)?

    All my delivery and/or store pickups are free.

    Just knowledgeable enough to be dangerous.

  6. #6
    Join Date
    Aug 2007
    Posts
    36
    Plugin Contributions
    2

    Default Re: new staticlist shipping module

    Hello Jacque --

    On which page would you want to hide the prices?

    I haven't yet experimented with this myself, but I'll bet if you wanted to hide the prices on, for example, the checkout_shipping page, you could comment out the relevant code in this file:

    includes/modules/pages/checkout_shipping/header_php.php

    You would probably also want to follow up with similar edits to other files under the pages directory:

    includes/modules/pages/

    It would be best to do this after having created your own template directory. Otherwise Zen Cart updates would likely overwrite your changes.

    Are all your shipping and delivery methods free? If not, I think I might leave the $0.00 showing to emphasize to your customers which ones are. On the other hand, if they're all free, I can see the benefit of simplifying the display during checkout.

    -- Rick

  7. #7
    Join Date
    Apr 2005
    Location
    Spokane, Washington
    Posts
    372
    Plugin Contributions
    0

    Default Re: new staticlist shipping module

    It's the checkout_shipping page I want to remove it from, but am unsure what code to comment out.

    All types of shipping are free, I'm just trying to clean up the page a bit.

    Love your contribution, it simplifies the checkout process a lot.

    Oh, greetings from the other side of the state (Spokane).

    jacque

    Just knowledgeable enough to be dangerous.

  8. #8
    Join Date
    Aug 2007
    Posts
    36
    Plugin Contributions
    2

    Default Re: new staticlist shipping module

    Jacque --

    I think I found it. I was way off before. Take a look at this file:

    includes/templates/template_default/templates/tpl_checkout_shipping_default.php

    Or if you have already setup your own template directory, find tpl_checkout_shipping_default.php within it. And then comment out the following lines like so:


    Code:
         <div><?php echo $quotes[$i]['error']; ?></div>
    <?php
            } else {
              for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) {// set the radio button to be checked if it is the method chosen
                $checked = (($quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $_SESSION['shipping']['id']) ? true : false);
    
                if ( ($checked == true) || ($n == 1 && $n2 == 1) ) {
                  //echo '      <div id="defaultSelected" class="moduleRowSelected">' . "\n";
                //} else {
                  //echo '      <div class="moduleRow">' . "\n";
                }
    ?><?php
                if ( ($n > 1) || ($n2 > 1) ) {?>
    
    <!--  JACQUE, COMMENT OUT THE FOLLOWING LINE TO PREVENT DISPLAY OF SHIPPING COSTS   -Rick
    <div class="important forward"><?php echo $currencies->format(zen_add_tax($quotes[$i]['methods'][$j]['cost'], (isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0))); ?></div>
    -->
    <?php            } else {?>
    
    <!--  JACQUE, COMMENT OUT THE FOLLOWING LINE TO PREVENT DISPLAY OF SHIPPING COSTS   -Rick
    <div class="important forward"><?php echo $currencies->format(zen_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax'])) . zen_draw_hidden_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id']); ?></div>
    -->
    
    <?php            }
    ?>
    
    <?php echo zen_draw_radio_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'], $checked, 'id="ship-'.$quotes[$i]['id'] . '-' . $quotes[$i]['methods'][$j]['id'].'"'); ?>
    <label for="ship-<?php echo $quotes[$i]['id'] . '-' . $quotes[$i]['methods'][$j]['id']; ?>" class="checkboxLabel" ><?php echo $quotes[$i]['methods'][$j]['title']; ?></label>
    <!--</div>-->
    <br class="clearBoth" />
    <?php
                $radio_buttons++;
              }
            }
    ?>

    I am working with Zen Cart 1.3.7.1. If you are working with a different version you may need to dig around to find the right lines to eliminate. Let me know how it goes.

    And likewise, greetings from the other side of the state. Looks like you run a neat operation there in Spokane. I'll stop by when I'm next out that way.

    -- Rick

  9. #9
    Join Date
    Apr 2005
    Location
    Spokane, Washington
    Posts
    372
    Plugin Contributions
    0

    Default Re: new staticlist shipping module

    Oh! That cleaned it up nicely, well done!

    I've ran into a new small issue though. I cloned the original files and renamed all files that reference staticlist to main_store_pickup.

    While the original file works great if you choose one of those options the cloned one just refers you back to the shipping page.

    Is this the error you mentioned in the beginning of this forum?

    Love for you to come by, just drop me an e-mail to remind me. I'll load you up with good organic travel food for the help you've provided (to me and the forum in general).

    jacque

    Just knowledgeable enough to be dangerous.

  10. #10
    Join Date
    Aug 2007
    Posts
    36
    Plugin Contributions
    2

    Default Re: new staticlist shipping module

    Jacque --

    Try the attached mainstorepickup.zip file.

    The files within are clones of the staticlist files. I used sed, a unix/linux utility, to make most of the changes. First line below catches upper case, second line catches lower case....

    Code:
    sed 's/STATICLIST/MAINSTOREPICKUP/g' staticlist.php > tempfile
    sed 's/staticlist/mainstorepickup/g' tempfile > mainstorepickup.php
    I did that to both files in the package, and then modified the language file as follows....

    Code:
    define('MODULE_SHIPPING_MAINSTOREPICKUP_TEXT_TITLE', 'Main Store Pickup');
    define('MODULE_SHIPPING_MAINSTOREPICKUP_TEXT_DESCRIPTION', 'Main Store Pickup');
    ?>
    Staticlist and mainstorepickup are working side by side in my test instance of Zen. I can go back and forth, work through the checkout pages, bounce back, select one of the options from the other shipping module, work through the checkout pages again. It all looks good. I think the bug that I mentioned at the start of this thread is pretty well resolved, so we shouldn't be seeing that particular behavior again.

    Thanks for the offer of some organic travel food. It'll probably be awhile, but I'm looking forward to it. And I'm completely into organic, as you can probably tell from my site.

    Cheers,
    Rick
    Attached Files Attached Files

 

 
Page 1 of 7 123 ... LastLast

Similar Threads

  1. staticlist and ot_cod_fee modules
    By g.nencini in forum General Questions
    Replies: 1
    Last Post: 10 May 2009, 04:22 PM
  2. Clone a shipping module or define a new shipping attribute under table rate module?
    By meeven in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 4 Sep 2007, 04:56 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