Avoid merging old cart items in customer session magento

In this post we will see how to avoid merging old cart items to the current checkout session.


  • It will be happen when we login to store and adds some products into cart and leaves store without purchasing.
  • Then coming back to the store after sometime and adds some product into cart without login and proceeds to checkout.
  • In checkout page we will be requested to login, after login we can see some additional products are added into the cart which we are added in previous session.
  • In this case what we have to do is we need to clear old cart items( It was requested by one of my client ) and allow customers to show with the current session items.

Continue reading

Upload SWF file in wordpress

Here is the code to Upload swf file in wordpress.

    function swf_upload($mimes) {
	if ( function_exists( 'current_user_can' ) )
		$unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' );
	if ( !empty( $unfiltered ) ) {
		$mimes['swf'] = 'application/x-shockwave-flash';
	return $mimes;

We can use Kimili Flash plugin to embed the flash file.

Magento file validation – prototype

Add file extension validation in magento form by using below code.

Validation.add('validate-jpg-png','Please upload only jpg/png file format!',function(the_field_value){
            if(the_field_value == '') return true;
            var extension = the_field_value.replace(/^.*\./, '');

            if (extension == the_field_value) {
                extension = '';
            } else {
                extension = extension.toLowerCase();
            switch (extension) {
                case 'jpg':
                    return true;
                case 'png':
                    return true;
                //you can add more case for valid extension.
                    return false;

To make it work add validate-jpg-png class to input file type.

<input type='file' name='avatar' id='avatar' class='validate-jpg-png' />