Saturday, January 28, 2012

Sorting Product Category Widget - WP E-Commerce Plugin Wordpress

Wordpress WP E-Commerce Plugin, There is a widget called Product Category Widget which lists all the product categories. During the site development you may have a lot of categories and nested categories then it will be difficult to sort the list. So here I'm helping you with a bit of code which will sort the products in the widget.

Method 1:

Edit the file :  /wp-content/plugins/wp-e-commerce/wpsc-widgets/category_widget.php
Add the below highlighted code to your php file.

$instance_categories = get_terms( 'wpsc_product_category', 'hide_empty=0&parent=0&orderby=name&order=ASC');
 function subval_sort($a,$subkey) {
            foreach($a as $k=>$v) {
                $b[$k] = strtolower($v[$subkey]);
            foreach($b as $key=>$val) {
                $c[] = $a[$key];
            return $c;
            $newArray = array();
            $tempI = $i;
            foreach($instance_categories as $key=>$value)
                $newArray[$i]['term_id'] = $value->term_id;
                $newArray[$i]['name'] = $value->name;
                $newArray[$i]['slug'] = $value->slug;
                $newArray[$i]['term_group'] = $value->term_group;
                $newArray[$i]['term_taxonomy_id'] = $value->term_taxonomy_id;
                $newArray[$i]['taxonomy'] = $value->taxonomy;
                $newArray[$i]['description'] = $value->description;
                $newArray[$i]['parent'] = $value->parent;
                $newArray[$i]['count'] = $value->count;
                $newArray[$i]['sort_order'] = $value->sort_order;
            $i = $tempI;
            $newArray = subval_sort($newArray,'name');
            $xyz = 0;
            $instance_categories = array();
            foreach($newArray as $key=>$value)
                $instance_categories[$xyz] = (object) $value;   

                foreach($instance_categories as $categories){

                    $instance['categories'][$categories->term_id] = 'on';

Method 2:  
You can use the below query also to fetch categories and can use it recursively for sub-categories.

    $results =$wpdb->get_results("SELECT name, slug
    FROM wp_term_taxonomy AS wtt
    JOIN wp_terms AS wt ON wt.term_id = wtt.term_id
    WHERE wtt.taxonomy = 'wpsc_product_category'
    AND wtt.parent =$category_id");

    foreach($results as $key=>$value)

  • name; ?>

  • }

Wednesday, January 25, 2012

PHPMailer with GoDaddy SMTP email script - Resolved.

Here is the working script for PHP Mailer in GoDaddy Hosting,



$email = '';
$firstName = 'Aravind';

$mail             = new PHPMailerR();
$mail->SMTPDebug                      = 1;                 
$mail->SMTPAuth                           = SMTP_AUTH;                $mail->Host                                   = SMTP_HOST;
$mail->Port                                    = 25;
$mail->Username                           =  SMTP_USERNAME;
$mail->Password                            = SMTP_PASSWORD;
$mail->Subject    = "Welcome to AravindNC.IN";
$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!";
$mail->MsgHTML('This is a test.');
$mail->AddAddress($email, 'Aravind NC');

Share this if you got it working.

Tags : PHPMailer with GoDaddy SMTP email server Script working,

Monday, January 23, 2012

Arshaw Full Calendar - Timezone fix

When we are pulling date from the server having UTC, it may display in local timezone format in Arshaw's Full Calendar. This is due to the misconfiguration in the full calendar function we are using. 

There is a constant for avoiding the timezone ie. ignoreTimezone, When parsing ISO8601 dates, whether UTC offsets should be ignored while processing event source data. The default is true, which means the UTC offset for all ISO8601 dates will be ignored. For example, the date "2008-11-05T08:15:30-05:00" will be processed as November 5th, 2008 at 8:15am in the local offset of the browser.

The below sample code shows how to use the ignoreTimezone in fullcalendar to avoid the local time constraint.

            eventSources: [
                ignoreTimezone: true
// For ignoring timezone
                left: 'prev,next today',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'
            editable: false,

Popular Posts