Latest Entries »

To prevent other shipping options to display once Free Shipping is available, add the following code to your template:
app/design/frontend/default/MYTEMPLATES/template/checkout/onepage/shipping_method/available.phtml

<?php
// Remove any other shipping methods if free shipping is available
if ( array_key_exists('freeshipping', $_shippingRateGroups )) {
    $_shippingRateGroups = array('freeshipping' => $_shippingRateGroups['freeshipping']);
}
?> 

credits go to AndrewNagy – source

I spotted a bug on Gala Color Swatches extension for Magento. The plugin’s code was failing if I used a negative price in configurable products tire pricing.

If you have the same problem, just replace all code of the app/design/frontend/default/your_theme/template/em_colorswatches/settings.phtml file with the following:

<?php
$swatches = $this->get_option_swatches();
?>
<!-- GALATHEMES: COLOR SWATCHES -->
<script type="text/javascript">
document.observe('dom:loaded', function() {
try {
var swatches = <?php echo Mage::helper('core')->jsonEncode($swatches); ?>;

function find_swatch(key, value) {
for (var i=0; i<swatches.length; i++) {
if (swatches[i].key == key && swatches[i].value == value)
return swatches[i];
}
return null;
}

function has_swatch_key(key) {
for (var i in swatches) {
if (swatches[i].key == key)
return true;
}
return false;
}

function create_swatches(label, select) {
// create swatches div, and append below the <select>
var sw = new Element('div', {'class': 'swatches-container'});
select.up().appendChild(sw);

// store these element to use later for recreate swatches
select.swatchLabel = label;
select.swatchElement = sw;

// hide select
select.setStyle({position: 'absolute', top: '-9999px'})

$A(select.options).each(function(opt, i) {

//if (opt.getAttribute('value')) {
if (opt.value) {

var elm;
var color_container;
var color_name;
var key = trim(opt.innerHTML);
var at_text = opt.innerHTML.replace('&nbsp;', ' ');
// remove price
if (opt.getAttribute('price')){
key = trim(key.replace(/[\+\-]([^+]+)$/, ''));
}
var item = find_swatch(label, key);
if (item){
elm = new Element('img', {
src: '<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); ?>swatches/'+item.img,
alt: at_text,
title: at_text,
'class': 'swatch-img'});
color_container = new Element('div',{'class': 'color_container'});
color_name = document.createTextNode(at_text);
}
else {
console.debug(label, key, swatches);
elm = new Element('a', {'class': 'swatch-span'});
elm.update(at_text);

}
color_container.observe('click', function(event) {
select.selectedIndex = i;
fireEvent(select, 'change');
var cur = sw.down('.current');
if (cur) cur.removeClassName('current');
color_container.addClassName('current');
});
color_container.appendChild(elm);
color_container.appendChild(color_name);
sw.appendChild(color_container);
}
});
}

function recreate_swatches_recursive(select) {
// remove the old swatches
if (select.swatchElement) {
select.up().removeChild(select.swatchElement);
select.swatchElement = null;
}

// create again
if (!select.disabled)
create_swatches(select.swatchLabel, select);

// recursively recreate swatches for the next select
if (select.nextSetting)
recreate_swatches_recursive(select.nextSetting);
}

function fireEvent(element,event){
if (document.createEventObject){
// dispatch for IE
var evt = document.createEventObject();
return element.fireEvent('on'+event,evt)
}
else{
// dispatch for firefox + others
var evt = document.createEvent("HTMLEvents");
evt.initEvent(event, true, true ); // event type,bubbling,cancelable
return !element.dispatchEvent(evt);
}
}

function trim(str) {
return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

$$('#product-options-wrapper dt').each(function(dt) {

// get custom option's label
var label = '';
$A(dt.down('label').childNodes).each(function(node) {
if (node.nodeType == 3) label += node.nodeValue;
});
label = trim(label);

var dd = dt.next();
var select = dd.down('select');
if (select && has_swatch_key(label)) {
create_swatches(label, select);

// if configurable products, recreate swatches of the next select when the current select change
if (select.hasClassName('super-attribute-select')) {
select.observe('change', function() {
setTimeout(function() {
recreate_swatches_recursive(select.nextSetting);
}, 100);
});
}
}
});
}
catch(e) {
alert("Color Swatches javascript error. Please report this error to support@galathemes.com. Error:" + e.message);
}
});
</script>

***tested on magento 1.6.2.0 community edition

It was really hard to find this, I hope it helps you:

$taxClassId = $_product-&gt;getData("tax_class_id");
$taxClasses = $this-&gt;helper("core")-&gt;jsonDecode( $this-&gt;helper("tax")-&gt;getAllRatesByProductClass() );
$taxRate = $taxClasses["value_" . $taxClassId];
echo 'tax: '.$taxRate.'%';

I found a very interesting and useful tutorial for creating Filterable Portfolio using jQuery. (you can read the full tutorial here)

The only disadvantage of this script is that you cannot create external links to your portfolio categories. After several hours of code manipulation, I finally found a solution. It’s based on the tutorial’s code so what you need to do is just replace some parts of the code.

Here’s the solution:

1) Replace the framework.js code with the following:

$(document).ready(function() {

	// LOAD THE URL SPECIFIED CATEGORY ON PAGE LOAD
	var filterVal = unescape(self.document.location.hash.substring(1));
	if(!filterVal){
		filterVal = 'all';
	}
	if(filterVal == 'all') {
		$('ul#portfolio li.hidden').fadeIn('slow').removeClass('hidden');
	} else {
		$('ul#portfolio li').each(function() {
			if(!$(this).hasClass(filterVal)) {
				$(this).fadeOut('normal').addClass('hidden');
			} else {
				$(this).fadeIn('slow').removeClass('hidden');
			}
		});
	}
	$('ul#filter .current').removeClass('current');
	$("#" + filterVal).parent().addClass('current');
	$("#" + filterVal).css('outline','none');

	//CLICK EVENT
	$('ul#filter a').click(function() {

		var filterVal = $(this).attr('id');

		$(this).css('outline','none');
		$('ul#filter .current').removeClass('current');
		$(this).parent().addClass('current');

		if(filterVal == 'all') {
			$('ul#portfolio li.hidden').fadeIn('slow').removeClass('hidden');
		} else {
			$('ul#portfolio li').each(function() {
				if(!$(this).hasClass(filterVal)) {
					$(this).fadeOut('normal').addClass('hidden');
				} else {
					$(this).fadeIn('slow').removeClass('hidden');
				}
			});
		}
	});

});

2) In index.htm file, replace the “<ul id=”filter”>…</ul>” list code, with the following:

</pre>
<ul id="filter">
	<li class="current"><a id="all" href="#all">All</a></li>
	<li><a id="design" href="#design">Design</a></li>
	<li><a id="development" href="#development">Development</a></li>
	<li><a id="cms" href="#cms">CMS</a></li>
	<li><a id="integration" href="#integration">Integration</a></li>
	<li><a id="information-architecture" href="#information-architecture">Information Architecture</a></li>
</ul>
<pre>

Now you can create links from external pages and view the projects of a single portfolio category by adding a “#category_name” at the end of the url. The “#category_name” represents the “href” attribute of each menu item. Also “category_name” has to be the menu item’s id.

I hope that was helpful.

In catalog and category list pages, there’s a toolbar at the top of the list, with some sorting options available. If you want to reverse the default sort order for these fields, do the following:

1) Open file app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php

2) You’ll find the following line near line 119:

protected $_direction = 'asc';

3) Replace the “asc” with “desc” and it’s done

I needed to create links to previous/next posts in my single post page in WordPress. I also needed to use images instead of text links and be able to navigate only in same category posts. This is the code I added in single.php file:

</pre>
<div class="previous_post"><!--?php previous_post_link('%link','<img src="' . get_bloginfo("template_directory") . '/images/previous_post.png" ?-->', TRUE); ?></div>
<div class="next_post"><!--?php next_post_link('%link','<img src="' . get_bloginfo("template_directory") . '/images/next_post.png" ?-->', TRUE); ?></div>
<pre>

For further explanation and reading, follow this page: http://www.kinocreative.co.uk/hints-and-tips/wordpress-nextprevious-post-navigation-with-images-and-inactive-links/

Coin Slider 4 WP is a simple and lightweight solution to create a featured posts slideshow in your wordpress site.

I spotted a bug in there though. I noticed that posts which were published more than 5-6 months ago would not appear in slideshow. It was clear that this was a post query issue, so I had to change the query_posts() call.

So, if you face the same issue, just open coinslider.php file and change the query_posts(…) code into the following:

query_posts('meta_key=csImage&amp;nopaging=true');

*Note that “csImage” is the name of the custom field you use to set post’s image url for slideshow. “csImage” is the default field name. If you changed that name with a custom name, in plugin settings page, you have to replace “csImage” in the previous code.

I you want to use a special pager layout for your magento-wordpress pages:

1) Create a new pager template file. Go to app/design/frontend/default/default/template/page/html/ directory, duplicate the pager.phtml file, and rename it to blog_pager.phtml.

2)Go to app/design/frontend/default/default/layout/wordpress.xml file and replace all instances of this line:

<block type="wordpress/post_list_pager" name="wordpress_post_list_pager"/>
with this one:
<block type="wordpress/post_list_pager" name="wordpress_post_list_pager" template="page/html/blog_pager.phtml"/>

Open file: /lib/Zend/Currency.php.

In line ~70 replace

'position'  => self::STANDARD,

with:

'position'  => self::LEFT,

http://www.fontis.com.au/blog/magento/custom-customer-signup-attributes

In order to make it work on 1.4.2, you have to add some rows in database manually. The solution is described in the page’s comments.

To set the order the new attributes display in backend Customer Account Data, you have to set the sort order manually. Open the customer_eav_attribute table in database, find the attribute you want based on attribute_id, and set the sort_order column.

UPDATE `customer_eav_attribute` SET `sort_order` = '112' WHERE `customer_eav_attribute`.`attribute_id` =990;

Create your own website, free on WordPress.com.Create your own website.
Start free