Forums / Addon Shipping Modules / new staticlist shipping module

new staticlist shipping module

Started by rriehle on 16 Oct 2007, 9:51 AM · Views: 22,926

Results 1 to 20 of 70
16 Oct 2007, 9:51 AM
#1
rriehle avatar

rriehle

New Zenner

Join Date:
Aug 2007
Posts:
36
Plugin Contributions:
1

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

21 Oct 2007, 1:36 AM
#2
rriehle avatar

rriehle

New Zenner

Join Date:
Aug 2007
Posts:
36
Plugin Contributions:
1

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

25 Oct 2007, 1:05 AM
#3
rriehle avatar

rriehle

New Zenner

Join Date:
Aug 2007
Posts:
36
Plugin Contributions:
1

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

25 Oct 2007, 7:09 PM
#4
jacque427 avatar

jacque427

Zen Follower

Join Date:
Apr 2005
Location:
Spokane, Washington
Posts:
324
Plugin Contributions:
0

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.

25 Oct 2007, 7:16 PM
#5
jacque427 avatar

jacque427

Zen Follower

Join Date:
Apr 2005
Location:
Spokane, Washington
Posts:
324
Plugin Contributions:
0

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.

25 Oct 2007, 8:11 PM
#6
rriehle avatar

rriehle

New Zenner

Join Date:
Aug 2007
Posts:
36
Plugin Contributions:
1

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

25 Oct 2007, 8:24 PM
#7
jacque427 avatar

jacque427

Zen Follower

Join Date:
Apr 2005
Location:
Spokane, Washington
Posts:
324
Plugin Contributions:
0

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.

25 Oct 2007, 11:51 PM
#8
rriehle avatar

rriehle

New Zenner

Join Date:
Aug 2007
Posts:
36
Plugin Contributions:
1

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:

     <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

26 Oct 2007, 12:46 AM
#9
jacque427 avatar

jacque427

Zen Follower

Join Date:
Apr 2005
Location:
Spokane, Washington
Posts:
324
Plugin Contributions:
0

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.

26 Oct 2007, 1:34 AM
#10
rriehle avatar

rriehle

New Zenner

Join Date:
Aug 2007
Posts:
36
Plugin Contributions:
1

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....

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....

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

26 Oct 2007, 3:20 PM
#11
jacque427 avatar

jacque427

Zen Follower

Join Date:
Apr 2005
Location:
Spokane, Washington
Posts:
324
Plugin Contributions:
0

Re: new staticlist shipping module

Beeeeutiful! You should offer it via the downloads for those that have more than one store with different options.

Thanks again and I look forward to meeting.

jacque

Just knowledgeable enough to be dangerous.

12 Nov 2007, 4:45 AM
#12
scootaman avatar

scootaman

New Zenner

Join Date:
Nov 2007
Posts:
74
Plugin Contributions:
0

Re: new staticlist shipping module

Hello,

I am wondering if this could help me with a need I have for shipping.

I am setting up a website to sell mopeds and I need the following options for shipping:

Business Address - free
Residential Address - $50.00
Residential Address with lift gate - $75.00

Would I be able to set this module to work that way?

12 Nov 2007, 4:47 PM
#13
rriehle avatar

rriehle

New Zenner

Join Date:
Aug 2007
Posts:
36
Plugin Contributions:
1

Re: new staticlist shipping module

Yes, that will work. The module installs and un-installs cleanly (at least on Zen 1.3.7.1) so if it doesn't quite do the job, it should be easy to back out and try something else. -- Rick

15 Nov 2007, 10:39 PM
#14
rriehle avatar

rriehle

New Zenner

Join Date:
Aug 2007
Posts:
36
Plugin Contributions:
1

Re: new staticlist shipping module

A picture, perhaps, is worth a thousand words. The screenshot shows the staticlist shipping module used to allow the customer to select from four Delivery options, each priced at $0.00. The descriptions and prices can be changed through the admin. This is one possible use of the staticlist shipping module. Change the heading "Delivery" to whatever works for your situation. The UPS module is shown for reference. -- Rick

16 Nov 2007, 12:19 AM
#15
jacque427 avatar

jacque427

Zen Follower

Join Date:
Apr 2005
Location:
Spokane, Washington
Posts:
324
Plugin Contributions:
0

Re: new staticlist shipping module

Good one!

Just knowledgeable enough to be dangerous.

4 Dec 2007, 2:47 AM
#16
remington avatar

remington

New Zenner

Join Date:
May 2005
Posts:
8
Plugin Contributions:
0

Re: new staticlist shipping module

Great module! It allowed me to add options for gift wrap without tearing my hair out. It's wonderful to be able to turn a customer's quick suggestion into possible $$$!

:clap:

4 Dec 2007, 3:33 AM
#17
rriehle avatar

rriehle

New Zenner

Join Date:
Aug 2007
Posts:
36
Plugin Contributions:
1

Re: new staticlist shipping module

Nice use of the module. I would not have thought of it.

Cheers,
Rick

4 Dec 2007, 4:29 AM
#18
yaeger4 avatar

yaeger4

New Zenner

Join Date:
May 2007
Posts:
4
Plugin Contributions:
0

Re: new staticlist shipping module

Does anyone know of a shipping module that set different shipping rules for different products. i.e.

sprocket A = little item can ship UPS, USPS, or Pick Up

hand truck = too big to ship UPS so it must go Customer Pick Up or Frieght

Marty

4 Dec 2007, 5:15 AM
#20
yaeger4 avatar

yaeger4

New Zenner

Join Date:
May 2007
Posts:
4
Plugin Contributions:
0

Re: new staticlist shipping module

Thanks!!! This is the best advise I've heard!! I'm going to implement it right away.

Marty

www.makenonline.com