Archive by Author

Using Zen-Cart as a “Cart Only” system

UPDATE: — 5/6/2010– For a working example of this method, Click here
The front-end is all done in Typolight, while the cart contents and checkout are handled with Zen-Cart.

I’ve seen this question has been asked many times before on the Zen-Cart forums with the same answer given each time: “It is not meant to be used like that, just make your whole site in Zen-Cart”.

Well, If you have ever used a CMS like Typolight, you know that by comparison, the “CMS” capabilities of Zen-Cart cannot compare by any stretch of the imagination.  However as an e-commerce platform, Zen-Cart is fantastic. It’s light, stable, and easy to modify. It just doesn’t stand up to the challenges that a web developer faces for managing a large site.  Some of the suggestions for pseudo integration involve sharing the header and footer HTML to try and get the zen-cart pages to  look like your existing site. Doing it this way it has the appearance that it’s at least somewhat integrated. The problem is, it isn’t and you still need to design pages in Zen-Cart.

Well,  I quickly found out that creating an “Add to Cart” button that can be added practically to any external page  made in any sort of CMS was very possible. In addition, it can be expanded even further using Jquery to create some amazing ajax effects that rival what is seen in systems like Magento and Freeway.

On with the show…

For my site, I started by installing to a sub-directory (domain.com/cart/) and stripping Zen-cart down to basic functionality by turning off all side boxes and links to categories, etc. Essentially, the only pages that will be served from Zen-Cart are the cart and checkout pages.  By editing the tpl_shopping_cart_default.php file, you can get a good feel for the cart structure and layout. For the fancy stuff, you will need to make changes to this file later.

I also setup my products but leaving out any kind of description since all that is handled on my other CMS.  Each Product is given an ID. This is what we will use to create the add to cart form buttons.

On the external page you wish to place your button, just past the following code:

<form enctype=”multipart/form-data” method=”post” action=”/cart/index.php?action=add_product” >
<input type=”text” name=”cart_quantity” value=”1″ />
<input type=”hidden” name=”products_id” value=”#” />
<input type=”submit” alt=”Add to Cart” value=”Add to Cart” title=”Add to Cart” />
</form>

Just replace the value=”#” with the number of the product.

When you click the add to cart button, it will then take you to the cart page where the product will be shown in the cart.  This form can also be further modified using a select list where you can have a dropdown to choose different products, hide the quantity box, etc.   It follows the same styling rules as any kind of form so it can be styled however you wish.

For basic level “Add to cart” button functionality, that is it. You don’t need to do anything further.

Getting fancy…

Now you can then get even fancier by using an invisible iframe and doing your submit to it so that the add to cart is actually handled in the “background” eliminating the page jump.

Just add the following to your page footer:

<iframe id=”cart_frame” src=”/cart/index.php?main_page=shopping_cart” name=”zenframe” width=”0″ height=”0″ style=”visibility:hidden”></iframe>

Then change your form to the following:

<form enctype=”multipart/form-data” method=”post” action=”/cart/index.php?action=add_product” target=”zenframe”>
<input type=”hidden” name=”cart_quantity” value=”1″ />
<input type=”hidden” name=”products_id” value=”#” />
<input type=”submit” alt=”Add to Cart” value=”Add to Cart” title=”Add to Cart” />
</form>

When you click add to cart, it will silently submit it to the iframe. You will want to add a link somewhere to open the cart page to see the results.   As a bonus of having the iframe load in your footer, the session stays active as your customer browses the site so you don’t lose the cart contents.   You can also just add the iframe and use it to keep the session active if you don’t want to do a silent submit.

Now, beyond this, you can use  JQuery to have messages appear such as “Item added to Cart” when you submit the form. This gives a nice ajaxy feel.  This can be done by creating a trigger tied to the form submit.

$(“form”).submit( function () {
// Your code to fade in a DIV and Fade Out
} );

By using the load() function, You can create a fully functional modal box that appears after you click add to cart that shows the cart contents and allows you edit it right there.  To accomplish this, You will want to create a hidden section on the zen-cart “Edit Cart” page that is customized for your modal pop-up.  I created a whole hidden cart section on the zencart side that the load() function pulls from.

Here is the Code I added in my Cart template. It is a modified duplicate of the default Cart display code that strips out a number of things I didn’t need and adds some DIV ID’s so I could grab various sections using Jquery.

<!–START HIDDEN MAIN CART THIS IS USED FOR THE POPUP CART IN EXTERNAL SITES –>
<div id=”maincartwrapperh” style=”display:none;”>
<div id=”cartInstructionsDisplay”><?php echo TEXT_INFORMATION; ?></div>
<?php if (!empty($totalsDisplay)) { ?>
<div><?php echo $totalsDisplay; ?></div>
<br />
<?php } ?>
<table  border=”0″ width=”100%” cellspacing=”0″ cellpadding=”0″ id=”cartContentsDisplay”>
<tr>
<th scope=”col” id=”scProductsHeading”><?php echo TABLE_HEADING_PRODUCTS; ?></th>
<th scope=”col” id=”scUnitHeading”><?php echo TABLE_HEADING_PRICE; ?></th>
<th scope=”col” id=”scQuantityHeading”><?php echo TABLE_HEADING_QUANTITY; ?></th>
<th scope=”col” id=”scTotalHeading”><?php echo TABLE_HEADING_TOTAL; ?></th>
<th scope=”col” id=”scRemoveHeading”>&nbsp;</th>
</tr>
<!– Loop through all products /–>

<?php
foreach ($productArray as $product) {
?>

<tr>
<td><span id=”cartProdTitle”><?php echo $product['productsName'] . ‘<span>’ . $product['flagStockCheck'] . ‘</span>’; ?></span></td>
<td><?php echo $product['productsPriceEach']; ?></td>

<td>
<form id=”securecart” enctype=”multipart/form-data” method=”post” action=”/cart/index.php?action=update_product” target=”hole”>
<div><?php echo $product['quantityField']?></div>
<div><input type=”image” title=”Update Quantity” alt=”Update Quantity” src=”/buttons/english/button_update_cart.gif”/></div>
<input type=”hidden” value=”<?php echo $product['id']; ?>” name=”products_id[]“/>
</form>
</td>

<td><?php echo $product['productsPrice']; ?></td>
<td>
<form id=”securecart” enctype=”multipart/form-data” method=”post” action=”/cart/index.php?action=update_product” target=”hole”>
<input type=”hidden” name=”cart_quantity” value=”0″ />
<input type=”hidden” value=”<?php echo $product['id']; ?>” name=”products_id[]“/>
<input type=”image” title=”Remove item from cart” alt=”Remove item from cart” src=”/cart/includes/templates/images/icons/small_delete.gif”/>
</form>
</td>
</tr>

<?php
} // end foreach ($productArray as $product)
?>
<!– Finished loop through all products /–>

</table>

<div id=”cartSubTotal”><?php echo SUB_TITLE_SUB_TOTAL; ?> <?php echo $cartShowTotal; ?></div>
<br />

<!–bof shopping cart buttons–>
<div><?php echo ‘<a target=”_blank” href=”‘ . zen_href_link(FILENAME_CHECKOUT_SHIPPING, ”, ‘SSL’) . ‘”>’ . ‘<img src=”/cart/includes/templates/buttons/english/button_checkout.gif” title=”Checkout now”  />’ . ‘</a>’; ?></div>
<!–eof shopping cart buttons–>
</div>
<!–END HIDDEN MAIN Cart Area–>

This gives us a custom area to pull data from that will be formatted on our external page.  The display:none keeps it from showing up when going to that page directly.

Because our iframe loads the cart page, we can use it to load up sections and display them.

I have this code in my header. It automatically is triggered after the iframe has loaded.

$(“#cart_frame”).load(function (){
var cartXitemsInCart = $(‘#cart_frame’).contents().find(‘div#cart’).html();
var cartTotalDollarAmt = $(‘#cart_frame’).contents().find(‘td.cartTotalDisplay’).html();
var cartFullCartDisplay = $(‘#cart_frame’).contents().find(‘div#shoppingCartDefault’).html();
var cartPopupDisplay = $(‘#cart_frame’).contents().find(‘div#maincartwrapperh’).html();
var cartEmptyMessage = $(‘#cart_frame’).contents().find(‘h2#cartEmptyText’).html();
$(‘#cartbox’).html(‘<h3>Your Stuff ‘ + cartXitemsInCart+ ‘</h3>’);

$(‘#cart_box_content’).html(cartPopupDisplay);
$(‘#cart_message’).html(cartEmptyMessage);
});

#cart_frame is the ID of the invisible iframe and so by specifying it above, we are using it as our source for pulling html from the page and loading it into variables that I can then display wherever I choose.  For example, By placing the var “cartPopupDisplay” into a #DIV I can make it appear on submit to show the cart contents and allow the customer to edit the contents or simply close the box and continue shopping. Also provided is a link to Checkout that will load the secure checkout screen in a new window.

I know this little tutorial isn’t the most complete and perhaps barely comprehensible, but hopefully contains enough information to help someone out.  Zen Cart CAN be used as a cart-only system, it just takes a little work.

Finally done

Finished the driveway extention over the weekend. Still sore from the shoveling, packing, moving, etc, etc.  No more mud pit everytime it rains. Should also prove to be of benifit during the snowy/icy winter months.
Finished Driveway Extention

As for the roots, Meet Mr 12″ Chop Saw.

Root Chopping

Pop quiz

How many roots can you pull out of the following  9′ x 18′  section of ground (6 inches deep)?

Section of recently dug out earth.

This many.

Lotsaroots

My weekend project. Needed to extend the driveway to the curb. A tree nearby made this a LOT harder than it needed to be.  However, in the end. Me 1 – Tree Roots – 0

Dumb like you’ve never seen it before.

In 1992, using a program called PC Animate Plus, I did a remake of Bambi Meets Godzilla. Nothing new really, just Bambi eating grass then a Godzilla foot stomps him flat. I did add blood spatter that hit the screen, so that was my creative addition.  That particular file seems to have been corrupt, BUT, What I do have is Part II and III. The two sequals were made in 1993 and 1994.  Part II was originally done on my 286 however got updated with a soundtrack and additional visual effects when we upgraded our computer to a Pentium 60.   Until today, they have been locked into a format that is only understood by ONE program. Thanks to DOSBox and it’s ability to capture to video, they are freed from this long dead application.  I have re compressed them to a WMV as the direct output from DOSbox had them at around 40MB each. Later I will re-encode them into Divx and perhaps get a little better quality and universal compatibility.

So, here they are in all their stupid glory.

Bambi Meets Godzilla II

Bambi Meets Godzilla III

This stuff doesn’t really qualify as geek material.. I think it passes into nerd territory.

Old Artwork

Buried in the recesses of my harddrive I found some pics I saved from a degrading 3.5″ floppy.  Both were made in 1991 using the state of the art PC Paintbrush IV+.  The machine I was using was a VGA equipped 286 made by some company that went out of business a long time ago (started with a Z I think). At anyrate, The first one was copied from a Sierra Interaction Magazine advertisement for the VGA remake of Liesure Suit Larry. No scanners involved (never even seen one at that time), It was done pixel by pixel.

Liesure Suit Larrt

The next picture I don’t remember where I saw the original, but,  I thought it would be fun to draw.  Again, hand drawn with a mouse, same program.

Anime woman

Prior to these, I had about 70 or so pictures I did on an 8088 in EGA graphics. Unfortunately, they were lost some time ago.

This final picture I did just today in about 45 seconds using Microsoft Paint.

Arrr I'm a Pirate!

-B

Classic adventure

Yes, I do love the Classics.

Classic Adventure TitlesWith the announcement (which I totally missed) of FreeSCI merging into ScummVM, I remembered I had bought these two titles off ebay awhile back.  I currently have every AGI adventure title Sierra produced on my Nintendo DS,  fully playable using the ScummVM port.

While visiting family over the holidays, I showed my nephew (who is about 10 years old I think 8 years old) Space Quest II running on the DS. He looked at me and said “That looks stupid.”   This was what I was playing when I about his age. He is currently playing the likes of Fallout 3.  I still think I had it better.

Testing.. Testing..

This is a test of Twitterfeed. Nothing special, just a test.

Edit:  Why isn’t this showing in the rss feed?

Starting in Ruby

I find I have a REALLY hard time keeping myself dedicated to learning something totally new without some kind of motivation beyond just “learning it”. For learning linux, my (initial) motivation was administering game servers. For learning Filemaker it was creating a database for tracking computers I built at my old job. Learning html/css it was Demopolislive.com and various other websites that I built.

So, I want to learn Ruby, but need some kind of goal and purpose. After some quick checking, I found one. My plan is to learn ruby through converting existing bash scripts and making future scripts for my IT job in Ruby. I deal a lot with making backup scripts and various other things in a number of linux servers, so this will be my starting point.

Visualizing Comcast Powerboost™

What Is Comcast Powerboost?

After upgrading the firmware in my Linksys WRT-54G router to Tomato , I was watching the wonderful real-time bandwidth graph that shows you exactly how much data is passing in and out of the router.  With this tool in hand, I thought I’d see exactly what exactly does “Powerboost” actually do for me.    I’m not disparraging it, as I can see it doing good for people who frequently download smaller files, say, single mp3′s, large images, etc.   But, if your looking for help in getting the latest Linux ISO, well, take a look.

Powerboost Visualized

Powerboost Visualized

Ok, so, it’s activated upon download and then quickly drops off. What if you paused the flow briefly, would the powerboost kick back in? Lets see.

Power Boost
Power Boost Experiment

Experiment

As you can see, yes it does. I’m downloading a large binary from Giganews using 10 connections to completely max out my download pipe. During the download, I simply hit the pause button on the app and click again to restart. I first stopped it for 5 seconds, then for 3, then one second. The last one is approx as I clicked unpause as soon as I saw the flow of traffic stop. Each time, the powerboost would kick in for the first 20MB.   The next thing I want to try is using the scripting capability of Tomato to somehow pause and restart downloads automatically to create a continous cycle of  “powerboosting”.   I really don’t need the speed, I’m just curious if it would actually work. From my preliminary research, I think it would.

If they could see me now..

Sometimes, I just test for no reason other than to see this.  A far cry from my first cable modem connection which ran at a blazing 512kb/s MAX.