Archive for the ‘cubecart’ Category

Submit is Not a Function (and getting links to submit all forms in CubeCart)

Saturday, March 15th, 2008

“Why am I getting that Javascript error?? WTH is it talking about - submit IS a function!!”

So here’s the deal - if you have a form and an element in the form is named “submit” - if you try to call document.myform.submit() - you’ll end up getting the “submit is not a function” javascript error. (Because to javascript - “submit” is now that object element in your form - not a function)

So the simple solution is if you plan on using the javascript function submit() - do not name any of your form elements “submit”.

That’s all well and good except if you’re working on code that isn’t completely yours - and if the PHP code to process the form is specifically looking for $_POST['submit'] like so:

if (isset($_POST['submit'])) { // process form }

then you now have another problem.

This was the case I ran into with CubeCart recently. Most of the forms do not require a submit element to be in the form in order to process it - but a handful did. The design I was working on needed all the buttons designed and to look the same. So my options were:

1) Just use the regular input type=”submit” button on those forms. (Ok - but then the site is inconsistent)

2) search for all instances of (isset($_POST['submit']) in the code and change it to some other element I can add to the page… ie:

<input type="hidden" name="formsubmitted" />

and then in the code:

if (isset($_POST['formsubmitted'])) { // process form }

(Obviously this is not recommended in the case of CubeCart as it will make it really annoying to maintain/upgrade the cart!)

3) add that other “formsubmitted” element I noted above to the pages that need it - then towards the top of the MAIN index.php page (which is called with all pages on the store) add the following:

if (isset($_POST['formsubmitted'])) $_POST['submit'] = 1;

Thereby setting the value of $_POST['submit'] so it will process the form…

Another tip with using css-styled links for buttons that will submit forms in CubeCart - you don’t need to use document.FORMNAME.submit() - from any form you can use their “submitDoc(’FORMNAME’)” function like so:

<a href="javascript:submitDoc('FORMNAME');" class="myButtonStyle">Send Form</a>

Just make sure the form has a name (some of them don’t).

Some CubeCart 4 minor mods (including select box image changer)

Saturday, January 5th, 2008

I’ve now used CubeCart 4 for a number of clients recently, and I have to say I’m pretty impressed. As with any cart - the features still have to match your needs, but for the most part, the clients I’ve implemented this for were able to get the features they had wanted. Then add in a few mods, and we’re in even better shape. I also want to mention that CubeCart 4’s support has been fantastic! Great customer service, helpful responses, with reasonable response time. They’re in a different time zone than me, but normal requests would be answered within a day - when I had a critical issue it was responded to within a few hours that same day. And as before, customizing their template has been pretty painless. I’ve been really happy with them and they’ve moved up to the top of my recommended list for cart software.

So to get things working just so with a few of my recent implementations, here are a some tricks I did: (Some of these little hacks were actually given to me by CubeCart’s support, although they do specifically say they don’t support changes to core application files.)
(more…)

Working with CubeCart

Friday, July 6th, 2007

As I wrote in the comments on this post, I have a new project that needed a shopping cart again. I tried Zen Cart again, and again I quickly remembered why I hated it so much. If I ever even so much as think of trying that package, just hand me the spork to remind me how I wanted to spork my eyes out everytime I use it.* Last time I really liked working with Cube Cart but ran into a problem with shipping and then went on a long hunt for something that did what I needed with shipping, was easy to modify templates, etc. etc. Since this time I didn’t have the same kind of shipping restriction, I figured I’d give Cube Cart another go. So far so good. Customizing has been a breeze. Very intuitive. I’ll be updating this post over the next few days with things I find useful as I work on the project (due next week! Wish me luck! heh)
(more…)