How to add special shipping by product in Zen Cart

February 9th, 2010 by Robert

I am in the process of migrating a static site (at peacemonger.org) to a database driven site “powered by” zen cart (at peacemonger.org/zencart for now). One of the features requested was the ability to add special shipping charges for odd shaped items, like posters.

After doing some research I discovered a page with instructions at http://tutorials.zen-cart.com/index.php?article=190, but it took me awhile to figure out how to implement them for the specific situation I was targeting. After reading the instructions a few times I realized that I had to really create an extra read-only text attribute to make my “special shipping” attribute be selected (as a single radio button) by default. Here’s what it looks like in the admin panel:

zencart attribute controller legend
zencart attribute controller, showing the options to add a required attribute to a product

And here’s what it looks like on the product page (the radio button is selected by default now, check it out at http://peacemonger.org/zencart/beatles-for-sale-22-x-33-poster-p-25626.html):

zencart shipping example

Though I just realized that the order is the opposite of what I want, even though I specifically set the order as noted above. Does anyone know why I can’t set the order in this way?

Update: I found a thread which helped me get the attributes sorted at http://www.zen-cart.com/forum/showthread.php?t=87470. The specific change I made which worked was to set the sort order for the attribute names, under Catalog -> Option Name Manager (they were all set to sort order 0 on that page before).

How to Hold a Handstand

January 30th, 2010 by Robert

Since I challenged the ASU men’s gymnastics team to a pommel horse circle competition a few months ago I’ve learned a great lesson about flexibility.  I was training on a mushroom leading up to the day I went into the gym, but after doing 74 circles on the mushroom I was only able to do 46 circles on the pommel horse when I went to the gym.

Then I began training with the mushroom top on the floor, but after a week or two I hit a barrier at 39 circles and realized that my inflexible wrists were preventing me from keeping my legs straight.  Because of this, I decided to stop doing circles and focus on my wrist flexibility.  I decided that I would be ready to do circles again when I was able to hold a handstand for a minute or two, so that was my goal and today I did a press handstand, got it on film, and posted my first video on Youtube:

You need to a flashplayer enabled browser to view this YouTube video

Empathy is the First Step in Making Up

November 10th, 2009 by Robert

This week I found the best video I have seen in a long time. It is a beautiful illustration of the power of empathy to change the world, one relationship at a time. The movie is called validation and is a bit of a play on words - the setting points to free parking validation but the main character validates people using empathy and compliments to help them smile. I enjoyed it very much, it is very uplifting for anyone that likes to be encouraged (I don’t know anyone who doesn’t!).


You need to a flashplayer enabled browser to view this YouTube video

I was inspired by the movie and attracted two different experiences that same day which emphasized the miraculous emotional healing that empathy can provide in relationships.

My wife Candice had been outside in the heat (yes heat, this is Phoenix in Nov) with one of our kids at a field trip with 47 1st-3rd graders that day (during her moon cycle), so she was a bit out of sorts. All the kids seemed to be asking her for things at once while she was getting dinner ready and she was trying to tell me about her frustrating day.

I really didn’t want to hear about it, but I made a conscious decision to show empathy by repeating what she had said in my own words - “You’ve been through a lot today and you just want a break, with some peace and quiet.”

Candice instantly lit up and gave me a big hug, then she didn’t say anything more about it - I was amazed!

Later while eating dinner Nickalus (who is 2) came to me crying:

“Bupaheay!
Bubahed!!
Bupaheyad!!!”

Finally I got the idea - “Oh, did you bump your head?”
“Yeaaah…” (as he nodded emphatically).
“That’s a bummer.” I replied, at which point he promptly calmed down and walked away. :)

It was as if I waved a magic wand and mended broken hearts with my words! Incredible!

I found an interesting book yesterday which uses empathy as part of the initial steps in the advice given to help people get their ex back. If you watch the first video on the page describing the Magic of Making Up, you’ll see how empathy is used in that situation - though it goes a bit further in agreeing with the other side of an argument, but the essence of showing an understanding of their position is really empathy at work - like magic.

How to recover from too much Halloween Candy

November 3rd, 2009 by Robert

Halloween Candy

Candice took the older three kids trick or treating for the first time this year, and they had a great time. Luckily it was on a Saturday so we had family over and they all went together, then watched a Scooby Doo mystery movie afterward (it goes with the spooky theme).

Of course during the movie they had their candy “loot” spread all over the floor in the TV room, and were happily gorging on assorted chocolate and sugar sweets. Near the end of the movie Kayin began doubling over in pain, screaming that his stomach hurt. So I put some nutmeg in a cup of water and gave it to him to drink. He said it helped and stopped screaming, and said he was fine as long as he had the cup with him. He was about to resume his feast when I reminded him that he already had too much and took his basket away for the night. :)

The next day Demitri broke out in a rash of little red bumps all over his skin so we felt good about putting away (not quite throwing away yet, but we’ll get there!) the rest of the candy in all three baskets. Demitri needed some rest so we put him to bed early that night after Candice gave him some herbs to help clear the toxins from his body.

The Key to Flexibility is Untimed Stretching

October 26th, 2009 by Robert

When I was a freshman in college, I sustained a head injury from a car accident which required me to relearn many basic functions, including walking, talking, and writing with a pencil. Arizona State University (where I went to school) has a very good disability support system. Due to my injury which happened over Christmas break, I was allowed to take untimed tests that spring. For most classes that didn’t matter, but for Physics that is the main reason I got an A in that class - hardly anyone finished those tests, but I remember sitting in the disabilities center for about 3 hours to finish each one.

That semester I didn’t get to compete on the gymnastics team either, but I did spend time in the gym, mostly stretching. Once I was able to workout again I was more flexible than before, which was great. I learned a great deal about how to improve flexibility from the times I was injured in college and could only stretch.

Giraffe Stretching

I learned that holding a stretch for 30 seconds or a minute during group stretches (where everyone is doing the same stretch) is much less effective than settling into a stretch and just relaxing and letting the world go by as if you weren’t there. Reading a book, talking to a friend, or even watching TV while stretching is great, so you can take your mind off it and relax.

These days, as I am doing circles on my mushroom almost everyday, I stretch for awhile soon after doing circles when my heart slows down a bit, and I also stretch at night before going to bed. I was just stretching at night, but since I’ve started doing circles again I know that I need to stretch my wrists right after working out in order to not tighten up. That way my nightly stretching can be helping me get more flexible instead of just catching up from the workout of the day (working out tightens muscles in general, so stretching is good to do after any type of workout).

So the next time you workout and feel the rush of endorphins, take the time to stretch and enjoy the natural, relaxing, good feelings of a healthy body. It will help you keep the good vibes going longer. If you want to gain flexibility, also pick another time in the day when you can either relax and meditate, or engage your thoughts in something else (like a book, homework, tv, or talking with a friend) while you stretch.

How to Overcome a Mental Block

October 14th, 2009 by Robert

Mental blocks can come in many forms, but they all come down to the thoughts we think.  Writers get “writer’s block”, actors get “stage fright”, and gymnasts (as well as other athletes) can develop an irrational fear about one specific trick or movement - like doing back handsprings on floor or beam, or doing release moves on the high bar or uneven bars.  Depending on the skill, some may argue that the fear is very rational(!), but it is still a mental game whether the fears are rational or not.

I often get asked about how to overcome mental blocks by gymnasts or their concerned parents over at allexperts, so I thought I would write a thorough post about the subject here that I can refer to.

Fear is a very powerful emotion that takes a little while to overcome.  On the emotional scale where feeling empowered is at the top (love, joy, and appreciation are all empowering), fear is at the bottom.  The following list of emotions is taken from page 114 of the book Ask and It Is Given (see amazon link below):

1. Joy/Appreciation/Empowered/Freedom/Love
2. Passion
3. Enthusiasm/Eagerness/Happiness
4. Positive Expectation/Belief
5. Optimism
6. Hopefulness
7. Contentment
8. Boredom
9. Pessimism
10. Frustration/Irritation/Impatience
11. Overwhelment
12. Disappointment
13. Doubt
14. Worry
15. Blame
16. Discouragement
17. Anger
18. Revenge
19. Hatred/Rage
20. Jealousy
21. Insecurity/Guilt/Unworthiness
22. Fear/Grief/Depression/Despair/Powerlessness

There are over 20 powerful processes detailed in that book which can help you move up the scale of emotions, and I’ve tried most of them successfully.  It is a wonderful reference for practical mind games you can play to help you feel better about any subject.

I remember going hiking with my ASU gymnastics teammates about 10 years ago in Oak Creek Canyon.  There was a waterfall at one point of the hike and we stopped to take a look.  Some of the guys decided it would be fun to jump off the ledge right next to the waterfall (about 30 feet up) into the pool down below.

I looked over the edge and was gripped with fear, so I sat back on a rock several feet away while others jumped off and climbed back up a few times.  I gave no indication that I was going to jump, so eventually people stopped egging me on.  I sat very still and calmed my breath, focusing my attention on the ground beneath my feet.  After awhile I had calmed down and was able to focus on the fact that the others were jumping and safely landing in the water below, and I worked my way up to feeling hopeful that I could do it too.

Waterfall like the one we jumped off in Oak Creek CanyonSo without any warning, when there was no one getting ready to jump or getting out of the water I stood up and quietly walked off the ledge.  My teammates were freaking out when I re-emerged because they didn’t expect me to jump and I had barely missed the rocks on the way down (because I didn’t jump I just walked off), but I didn’t care because I had done it and I was done. :)

I remember having several other mental blocks with specific gymnastics skills (like every release move I ever tried on high bar!), which are actions to take over and over (not just once with the cliff jumping example above).  The most success I had overcoming these mental blocks happened over periods of time when I could “play” with different aspects of the skills (either in my mind or on the equipment) but not really focus on them or bring attention to the fact that I was playing with them.  Just like in the example above, I had to remove myself from the situation and work my way up the emotional scale on my own (without the pressure or attention of anyone else) before I could approach it from a different perspective.  Then once I felt better about it I would try it on my own (or ask for a spot or a belt if I was ready for that), but without much fanfare.

Regarding specific gymnastics skills (like backwards tumbling, cartwheels, kips, jumping from the low bar to the high bar, release moves, etc.), I believe that when a mental block is developed a break is needed from whatever skill it is to focus on others that are easier and very comfortable.  Recently I’ve been skateboarding for fun at a skate park near my house, and it helps me to do something like that which is totally different from my work or family life in order to gain a fresh perspective on whatever I’m stuck on, whether it’s a programming issue or a parenting one.

The length of the break really depends on how long it takes to feel better.  In the example above I was able to feel better about jumping off a cliff in a matter of minutes, but when fearful thoughts are practiced over time about a given subject it may take some time to believe different thoughts that are more hopeful and empowering.

It can help to talk about the subject if the people you talk with can help you reach for thoughts that feel better, but it is not necessary and will hinder progress if the person you talk with is frustrated about the situation.  When I was training in gymnastics I learned how to block out my coach or teammates at times when I was ready to try something again after taking a break, because they were usually still frustrated about my previous attempts.

Born to be Free

October 5th, 2009 by Robert

We had a birthday party for our youngest child yesterday and something happened which reinforced the middle name we gave him.  Candice had bought a birthday cake that morning and I put it on the counter by the stove pushed against the back wall in a corner of the kitchen.  About an hour later, while I was outside cleaning up the yard, Candice came out of the house holding Hani out by his arms while he wiggled like the whirling dervish that he is, and said:

Hani - Born Free

“This is why you don’t put cake on the counter!”

While Candice was on the phone, Hani had come to her holding the cake upside down (luckily it was in a plastic container he couldn’t open) and shaking it, saying “Cake!  Cake!” - apparently he had moved a chair from the table across the room to the counter right where the cake was in the back corner, then just climbed up and retrieved his prize.

Hani’s middle name is Fungasa, which means “liberate yourself”.  I took his picture (above) a few days ago while he was practicing his Harley style of freedom. :)

You can get help finding your own freedom here.

Learning a Glide Kip - it’s all about the Swing

September 16th, 2009 by Robert

I have received quite a few questions about glide kips over at allexperts, so I thought I would write a summary of my suggestions in one place that I can refer people to.  It is a skill that is tricky for many people because it is not based on strength, flexibility, or balance - it is the swing that matters most.

The kip can be tricky to learn, but the trick is to use your body to your advantage.  Here are the 3 key movements I think it helps to think about:
1)  When you scoop your feet under the bar just above the floor (depending on your height), you want to get your feet as far up as you can and extend your body as far as you can from the bar before you change direction.
2)  As soon as you feel yourself coming back down, you want to get in a tight pike with your feet about a tennis ball away from the bar (and your hands) while your nose is almost between your knees
3)  As you swing back, you’ll want to start pulling the bar towards your hips (after you pass under the bar) but keep the bar right next to your straight legs while pulling it.

I’ve tried it on a trapeze before and actually hit my head with the bar the first time because I was used to a stationary bar!  After a few tries I was able to do a kip on the trapeze, though I had to adjust my swing and keep my arms straight in order to get up without hitting my head.

But on the playground or in a gym, the proper swing will take you up to a hip support on top of the bar, which is fun and feels very satisfying for me even after 24 years. :)

How to import and export large datasets in mysql

September 14th, 2009 by Robert

I’ve seen many questions around the importing and exporting of large tables and/or databases in mysql, so I’d like to share how I’ve learned to manage those processes.  Using phpmyadmin for these tasks is not suitable because web servers are not designed for running large scripts or uploading/downloading large files.  You can changes the limits in phpmyadmin but there are several different limitations in that environment which you may run into.

For exporting large databases you can use the mysqldump command from a prompt (unix shell or dos prompt).  For exporting large tables, I login to mysql and use a query with the syntax “SELECT column1name, column2name, column3name, … FROM myDatabaseName.myTableName INTO OUTFILE ‘/path/to/outfilename.csv’ FIELDS TERMINATED BY ‘,’ ENCLOSED BY ‘\” ESCAPED BY ‘\\’;” - this gives you a csv file in the location you specify with the fields surrounded by single quotes, separated by commas, and escaped by a backslash.  The only thing that needs to be escaped in this context is a single quote.

For importing large databases created from mysqldump or phpmyadmin, I save the sql dump file into a local directory, cd to that directory (in unix shell or windows dos), login to mysql from the command line, then type the following command: source dbdump.sql (or whatever the dump file name is with your db data).

For importing large tables that were exported using the export syntax I mentioned above, I login to mysql and then type something like “LOAD DATA INFILE ‘/path/to/outfile.csv’ INTO TABLE myDatabaseName.myTableName FIELDS TERMINATED BY ‘,’ ENCLOSED BY ‘\” ESCAPED BY ‘\\’;”

The Essence of AJAX - How I learned it in an hour

September 6th, 2009 by Robert

I was a bit resistant to learning ajax for a couple years because I didn’t see a need for it in the programs I was developing.  However, one day I learned it without knowing it.  I was working with code written by someone else which called a javascript function that invoked a url, then called another function to handle the results of the url.  An example that looks very similar to the code I was working with is at http://www.captain.at/howto-ajax-form-post-request.php.

If you look at that code, there are 3 javascript functions used - get (this is called from clicking on a button in the form on the page), makePostRequest (this is the function which calls the url and sends parameters to it via the post method), and alertContents (this function is called from the makePostRequest function when the response is received from the url).

The get function just creates a string with parameters to pass, defines an url, and then passes them to the makePostRequest function.  Here are the main lines of code in the makePostRequest function and what they mean:

  • http_request.onreadystatechange = alertContents; - this says when the http_request.readyState changes, then call the alertContents function.
  • http_request.open(’POST’, url, true); - this defines what url is going to be called and what method is going to be used
  • http_request.send(parameters); - this sends the parameters specified in the post array to the url requested

There are a few other lines specifying a the header of the request, and a bunch of lines in the beginning that setup the http_request object to work for different browsers.

Then in the alertContents function (which is actually called several times, whenever the readyState changes), once the readyState of 4 is reached (you can read more about readyStates at http://www.yaldex.com/wAjax/DiggingdeeperintoHTTPreadystates.html) the http status is checked.  If the status is 200 (and not 404, 501, 301, etc. - see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for a full list with explanations) then the result of that http request (like what you would get if you put that url into a browser address bar and sent the appropriate post parameters in the header - done through a script, not a browser - then checked the page source) is stored into a javascript variable and you can do whatever you want with it.

In that example they just stick it into a span element on the existing page, but you can do many other things.  If you invoke an url which takes as parameters the values of certain form elements on the page, you could return a list of values to populate another dropdown with, etc.  So you can take the example and modify the parameters passed, what the invoked url does, and what is done with the results - then you will have your own ajax function!