Customize your Virtuemart shopping cart in Joomla

by Koree Monteloyola

 

Here are some customizations for your Virtuemart shopping cart in Joomla.

To make the pop-up notification box more readable (because sometimes the background color is set to light yellow and the text is set to white), edit the following:

file:

path/to/joomla/components/com_virtuemart/themes/default/theme.css

text to edit:

.shop_error, .shop_warning, .shop_info, .shop_debug, .shop_critical, .shop_tip {
background-color:#FAFAD2;
background-position:left 5px;
background-repeat:no-repeat;
border-color:#AACCAA;
border-style:dotted none;
border-width:1px 0pt;
font-weight: 900;
margin:1pt 1pt 1em 1em;
padding:0.5em 1em 1.5em 48px;
color:#000000;
}

To remove the Virtuemart shopping cart logo, when the cart is empty, edit the following:

file:

path/to/joomla/components/com_virtuemart/themes/default/templates/common/minicart.tpl.php

text to edit:

   if(!$vmMinicart) { 
<a href="http://virtuemart.net/" target="_blank">
<img src="<?php echo $mm_action_url ?>components/com_virtuemart/shop_image/ps_image/menu_logo.gif" alt="VirtueMart" width="80" border="0" /></a><br />
}

To remove the "Categories" text in Virtuemart shopping cart, edit the following:

file:

path/to/joomla/components/com_virtuemart/themes/default/templates/common/shopIndex.tpl.php

text to edit:

echo "<br /><h4>".$VM_LANG->_('PHPSHOP_CATEGORIES')."</h4>";

 

VirtueMart error: Credit Card Type not found

by Koree Monteloyola

 

I have just discovered what causes the "Credit Card Type not found" error in VirtueMart.

First problem : the "Credit Card Type" drop down box isn't displaying...this lead me to the 2nd problem, which is

Second problem : A javascript "writeDynaList" function is required, but is not included in your current javascript functions. So where will you find it?...moving on to the third problem

Third problem: the "writeDynaList" is inside the "JURI::root(true).'/includes/js/joomla.javascript.js'", but the javascript file isn't loading. WHY NOT?

The explanation can be found through this snippet of code in your <joomladirectory>/includes/application.php, and string search for this condition:

if ( $user->get('id') ) {
                    $document->addScript( JURI::root(true).'/includes/js/joomla.javascript.js');
                }
}

This means, that the user has to be logged in to load the javascript file.

If you want to force your customers to login during checkout, go to:

Administrator->Component->Virtuemart->Configuration->Global->User Registration Settings

then set the value of "User Registration Type" to "Normal Account Creation"

 

Hope this post helps you. Cheers!

 

Become a better programmer

by Koree Monteloyola

 

Shouldn't that be a long term goal?

It sort of comes with the vocation, right?

I'm hoping that the following list would help and/or inspire you somehow.

So here goes...


1. "Do it right the first time"

    Always remember this whenever you build something - especially for big projects. I know there are several approach on how to build or solve something, but what it really means is you should try to give your best (as long as you can), or if you have no idea what is the best approach, research and don't be afraid to ASK!

    Of course there is "no perfect" program and bugs are always expected; but if you managed to minimize the anomalies in your codes, it would save you a lot of time and unnecessary headaches in the long run.

2. Think ahead

    This supplements tip #1 - you have to visualize the end product and the ways and tools to achieve it. Also, create the project in a flexible way wherein code modifications are easy to incorporate.

3. Read on and read good

    I know it's boring and strenuous to read manuals, tutorials, ebooks etc etc, but trust me you will benefit from the long hours and efforts you spent on that ass-flattening thick book.

    Aside from the supplements mentioned above, you should take advantage of the source codes that are freely distributed on the internet, such us, joomla, drupal, wordpress and many more. Download the packages and scrutinize the culture, style and art on how the system was built.

4. Breakdown that complicated process

    It's normal to be overwhelmed by a complicated process, the next thing you should do is to analyze and disintegrate the process into smaller functions, and work on it one by one. I bet by then it wouldn't be that much scary.

5. Programming is in the heart
   
    Like what they say, "Many are called, few are chosen", what would really make you stay and strive to become better at this profession, is your passion and patience, and most of the time, in my case, a kick-ass background music.

6. Practice and evolve *repeat until fade*

    Unlike other occupations, software engineering evolves at a much faster pace, there's always something new on how to build and execute digital operations, in just a matter of months.

    Warning: Slackers would be terribly punished.

7. Self-criticize your work

    I believe that from time to time you should interact with other programmers and have them check your codes, I believe that if the other programmer is not a douche, he/she would teach you on how to do a certain process faster, and that my friend would save you a lot of time. Remember, there's someone who's always better than you at something.

8. Be lazy in a smart way

    In reality this means you should practice reusing your codes and improve ways to "shorten" the lines of your codes while having the same or better output.
    Write your functions in a good way so next time you would be spending less time on creating similar projects.


That's all code warrior, cheers!

Category: Programming

Image Manipulation : Watermark images on the fly through PHP and GD

by Koree Monteloyola

 

Let's say you're given a hundred "digital" images and you need to put watermarks on each of those photos.

If you're going to do this manually, man! It would eat a lot of your time.

So here's a solution: a php script that would automatically merge a watermark to an image.

Requirements:

  • PHP 4+
  • GD 2.0+ Library
  • watermark file should be saved as PNG-8, not PNG-24.


<?php
$err=0;
if(empty($_GET['path'])){
    $path = 'images/wrongPath.gif';
    $err++;
}else{
    if(!is_file(getcwd().'/images/'.$_GET['path'])){
        $path = 'images/wrongPath.gif';
    }else{
        $path = 'images/'.$_GET['path'];
    }
}
$srcImage = $path;
header("Content-type: " . image_type_to_mime_type(exif_imagetype($srcImage)));
switch(exif_imagetype($srcImage)){
    case IMAGETYPE_GIF:
        $image = imagecreatefromgif($srcImage);
        break;
    case IMAGETYPE_JPEG:
        $image = imagecreatefromjpeg($srcImage);
        break;
    case IMAGETYPE_PNG:
        $image = imagecreatefrompng($srcImage);
        break;
}
if(empty($err)){
    $watermark = imagecreatefrompng(getcwd().'/images/watermark.png');
    $watermark_width = imagesx($watermark);
    $watermark_height = imagesy($watermark);
    $size = getimagesize($srcImage);
    $dest_x = $size[0] - $watermark_width - 10;
    $dest_y = $size[1] -$watermark_height - 10;
    imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);
}
switch(exif_imagetype($srcImage)){
    case IMAGETYPE_GIF:
        imagegif($image);
        break;
    case IMAGETYPE_JPEG:
        imagejpeg($image);
        break;
    case IMAGETYPE_PNG:
        imagepng($image);
        break;
}
imagedestroy($image);
imagedestroy($watermark);
?>


You can download a sample of the script here.

jEdit : A text editor for programmers

by Koree Monteloyola

 

I have been a web programmer for 5 years and I have been faithful to only 3 text editors, namely: Maguma, Dreamweaver and jEdit.

Among the 3, jEdit is my "weapon of choice". Again, this tool was introduced to me by k0n, because he's a show off. (haha! just kidding)

jEdit is written in Java and I've tried using it on Linux and Windows. It also has support for other programming & scripting language, such as java, perl, asp, php..and a lot more, you can see the list under Global options > Editing > Change settings for mode drop down box

What makes this text editor powerful is the plugins you can install to make it an advanced XML/XHTML text editor or an IDE.

Here is a screenshot of the "must have" plugins I use.

jedit2

If you're using PHP, you should definitely install PHPParserPlugin and SideKick.

One of the "cool" things you can do with this editor is customizing the look&feel; if you notice I use a black background, to reduce the stress on my eyes, and I can have an upbeat Saito Hajime background image, like so:

jedit3

Looks cool, eh?

So give this text editor a try, download it now!

 

Page: 1 2