Blog Category: Web Design

Simple Mobile Menu for Shopify

Do you need to add a mobile menu to your shopify theme? This is a pretty easy process when done correctly. In shopify go to your theme.liquid. In there you will want to look for some code that looks like this (might be slightly different depending on your theme)
[Read more…]

Downloading All Images, HTML, CSS, Javascripts and PDFs from SSH

Downloading All Images, HTML, CSS, Javascripts and PDFs from SSH

Need to migrate\back-up a web site that you don’t have access to the core files?  Going through manually by hand is annoying and can take forever.  Here is a simple script to download a majority of the web site files.  It will not download files hosted on CDN’s or other domains, but it is a good starting point.  First login to your linux or unix box. Then type the following command.

Note that if you do this too often, you might get blocked or kicked from a server, so beware of trying to take too much information too fast.

wget -r P . -A jpg,jpeg,gif,png,html,css,txt,php,pdf,js http://www.domainname

Now sit back and watch your machine do the work.

Magento Delete Old Credit Card Numbers – Solved

Magento Delete Old Credit Card Numbers - Solved

Here is a quick tutorial on how to clear credit card numbers. I will include a few scripts that you might helpful. BACKUP YOUR DATABASE. If you don’t back up your database before running these scripts you are playing with fire. So always, back-up before running the scripts.

Magento Clear Credit Cards of Complete and Canceled Orders

Here is a script to clear credit cards for complete or canceled orders. Place this script into a php file on the root level of your magento installation. Wherever you see files like app, skin, var.

<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

require_once('app/Mage.php');
Mage::app();

$orders = Mage::getModel('sales/order')->getCollection()
   ->addFieldToFilter('status', array('in' => array('canceled','complete')))
   ->addAttributeToSelect('status')
   ->addAttributeToSelect('increment_id')
   ->addAttributeToSelect('entity_id')
   ->addAttributeToSelect('quote_id')
   ->addAttributeToSelect('created_at');

$prefix=(string)Mage::getConfig()->getTablePrefix(); // Get Prefix

// fetch write database connection that is used in Mage_Core module
$write = Mage::getSingleton('core/resource')->getConnection('core_write');

foreach ($orders as $order) {
    $IncrementId = $order->getIncrementId();
    $OrderStatus = $order->getStatus();
    $EntityId = $order->getEntityId();  // Very Important
    $QuoteId = $order->getQuoteId(); // Very Important
    $year = date('Y', strtotime($order->getCreatedAt()));

           $updatefirsttable = "update ".$prefix."sales_flat_quote_payment set cc_number_enc=null where quote_id=".$QuoteId."";
           $updatesecondtable = "update ".$prefix."sales_flat_order_payment set cc_number_enc=null where entity_id=".$EntityId."";

           $write->query($updatefirsttable);  // Update Quote
           $write->query($updatesecondtable); // Update Order
            echo "Increment ID";
            echo $IncrementId;
            echo ' Quote id: ';
            echo $QuoteId;
            echo ' Entity IdL ';
            echo $EntityId;
            echo ' Year: ';
            echo $year;
            echo '<br/>';

}
echo "complete";

This should go through and remove all of the credit cards for completed and canceled orders. It should also print out to the Increment ID, Quote, Entity ID and Year, this is so you can troubleshoot it if there is an error.

Clearing Pending Credit Cards from Magento by Year

I had a client that needed to clear credit cards for items that were considered PENDING because they never updated them to complete. So I wanted to clear everything before the year 2015. So I just made a few modifications to the script. This clears all pending orders credit cards before the year 2015. You can update it to your year by changing 2015 to whatever year you want.

<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

require_once('app/Mage.php');
Mage::app();

$orders = Mage::getModel('sales/order')->getCollection()
   ->addFieldToFilter('status', array('in' => array('pending')))
   ->addAttributeToSelect('status')
   ->addAttributeToSelect('increment_id')
   ->addAttributeToSelect('entity_id')
   ->addAttributeToSelect('quote_id')
   ->addAttributeToSelect('created_at');

$prefix=(string)Mage::getConfig()->getTablePrefix(); // Get Prefix

// fetch write database connection that is used in Mage_Core module
$write = Mage::getSingleton('core/resource')->getConnection('core_write');

foreach ($orders as $order) {
    $IncrementId = $order->getIncrementId();
    $OrderStatus = $order->getStatus();
    $EntityId = $order->getEntityId();  // Very Important
    $QuoteId = $order->getQuoteId(); // Very Important
    $year = date('Y', strtotime($order->getCreatedAt()));

    if ($year < 2015) {

           $updatefirsttable = "update ".$prefix."sales_flat_quote_payment set cc_number_enc=null where quote_id=".$QuoteId."";
           $updatesecondtable = "update ".$prefix."sales_flat_order_payment set cc_number_enc=null where entity_id=".$EntityId."";

           $write->query($updatefirsttable);  // Update Quote
           $write->query($updatesecondtable); // Update Order
            echo "Increment ID";
            echo $IncrementId;
            echo ' Quote id: ';
            echo $QuoteId;
            echo ' Entity IdL ';
            echo $EntityId;
            echo ' Year: ';
            echo $year;
            echo '<br/>';
    }

}
echo "complete";

How To Integrate WordPress Posts on a Magento Site – The Easy Way

How To Integrate Wordpress Posts on a Magento Site - The Easy Way

There are lots of plugins and tutorials out there that try to explain how to integrate WordPress recent blog posts on a Magento site. With all of them you have to either download plugins, establish a wordpress connection, and tweak some Mage code. I have found that if you are just trying to display recent blog posts onto the homepage of your Magento website, there are much easier ways. Just make an snippet that gathers the information from the RSS feed.

I had a client that wanted two display the latest blog post onto the homepage of their Magento site. So I simply went to /app/design/frontend/themename/themename/pages/home.phtml and place in the following code.

<?php
	$channel = new Zend_Feed_Rss('http://example.com/feed');
	$i = 0;
	foreach ($channel as $item):
		if($i < 1) {
			echo '<h5>'.$item->title.'</h5><br/>';
			preg_match_all("/<p>(.*?)<\/p>/si", $item->description, $paragraphs);

			echo $paragraphs[0][0];
			echo $paragraphs[0][1];

			echo "<a href='".$item->link."'' class='readmore'>Read more &gt;&gt;</a>";
			break;
		}
		$i++;
	endforeach;
?>

That’s it, bingo bango. That is a lot easier that trying to make a silly connection.  Just change the Zend_Feed_RSS with your domain name and rss feed location. If you want to show more than one item, then change $i < 1 to whatever number you want.

I hope you find this easier than all the other nonsense.

*As  a note, I made a filter to only display the first to paragraphs.  If you don’t want this you can remove this….

preg_match_all("/<p>(.*?)<\/p>/si", $item->description, $paragraphs);

echo $paragraphs[0][0];
echo $paragraphs[0][1];

and make it this..

echo $item->description

Tri.be The Event Calendar Custom Shortcodes

Tri.be The Event Calendar Custom Shortcodes

If you are using Tri.be’s WordPress Event Calendar, sometimes you might want to display event information in a page using a shortcode. Unfortunately the plugin doesn’t have this out of the box, but luckily it is easy enough to add.

First go to your themes function.php file and back-it up.

Second paste in the following code:

add_shortcode('event_code', 'events_shortcode');
function events_shortcode() {

	$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
	$upcoming = new WP_Query();
	$upcoming->query( array(
		'post_type'=> 'tribe_events',
		// 'eventDisplay' => 'past',
		'posts_per_page' => 3,
		'paged' => $paged)
	);
	$return_string = '';
	if ($upcoming->have_posts()) :
		while ($upcoming->have_posts()) :
			$upcoming->the_post();
			$return_string .= '<strong><a href="'.get_permalink().'">'.get_the_title().'</a></strong> <br/>';
			$return_string .= tribe_events_event_schedule_details();
			$return_string .= '<br/><br/>';
		endwhile;
		if ( function_exists('wp_pagenavi') ) wp_pagenavi( array( 'query' => $upcoming ) ); // tell it which query we are paginating
	endif;
	wp_reset_query(); // important to reset the query
	$return_string .= '<a href="'.tribe_get_events_link().'">View All Upcoming Events</a>';
	return $return_string;
}

Next go to the page you would like to add the shortcode. On this page add the following.

[event_code]

Save the page, and now you should see some event information. If you would like to view more or less events on the page edit value in the above code. For example, if you want to change from showing 3 events to 2, go to:

'posts_per_page' => 3,

And change the 3 to 2.

'posts_per_page' => 2,

That is it!

If you have any questions please feel free to contact me through the comments section below. Also be sure to checkout my Visalia Web Design services.

Solve PHP Fatal error: Class ‘Mage_Enterprise_Rma_Block
_Adminhtml_Product_Renderer’

Solve PHP Fatal error: Class 'Mage_Enterprise_Rma_Block<br/>_Adminhtml_Product_Renderer'

Here is how to fix the following magento error after down-grading from enterprise to community.

PHP Fatal error: Class ‘Mage_Enterprise_Rma_Block_Adminhtml_Product_Renderer’ not found in /lib/Varien/Data/Form/Abstract.php on line 146

Login to your mysql and execute the following code:


DELETE FROM eav_attribute WHERE `attribute_code` = 'giftcard_amounts';
DELETE FROM eav_attribute WHERE `attribute_code` = 'related_tgtr_position_limit';
DELETE FROM eav_attribute WHERE `attribute_code` = 'related_tgtr_position_behavior';
DELETE FROM eav_attribute WHERE `attribute_code` = 'upsell_tgtr_position_limit';
DELETE FROM eav_attribute WHERE `attribute_code` = 'upsell_tgtr_position_behavior';
DELETE FROM eav_attribute WHERE source_model LIKE 'enterprise_%';
DELETE FROM eav_attribute WHERE backend_model LIKE 'enterprise_%';
DELETE FROM eav_attribute WHERE attribute_code IN ('gift_wrapping_available', 'gift_wrapping_price');

Bingo bango, problem solved

Answer found on stackoverflow
http://stackoverflow.com/questions/13415426/fatal-error-class-mage-enterprise-rma-block-adminhtml-product-renderer-not-fo

OSCommerce Blank Admin Login

I was given the task to upgrade some old oscommerce stores, when I did I noticed an error when trying to reach the admin panel. Here are items I did to fix all the different errors so I could finally sign into the account.


PHP Fatal error: require() [function.require]: Failed opening required '/catalog/includes/classes/action_recorder.php' (include_path='.:') in /catalog/admin/includes/classes/action_recorder.php on line 13

The first error I ran into was a PHP Fatal error because of action_recorder.php, to fix this error make sure your configure.php files are correct. If they are then simply download /catalog/admin/includes/classes/action_recorder.php and /catalog/includes/classes/action_recorder.php from the package, then re-upload them, this got the error to go away for me.

The next error I was receiving was that there wasn’t an administrators table. So I login to phpmyadmin and execute the following…


-- phpMyAdmin SQL Dump
-- version 2.11.9.6
-- http://www.phpmyadmin.net
--
-- Host: localhost:3306
-- Generation Time: Apr 10, 2014 at 02:20 PM
-- Server version: 5.0.77
-- PHP Version: 5.2.6

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `coslair_db1`
--

-- --------------------------------------------------------

--
-- Table structure for table `administrators`
--

CREATE TABLE IF NOT EXISTS `administrators` (
`id` int(11) NOT NULL auto_increment,
`user_name` varchar(255) character set utf8 collate utf8_bin NOT NULL,
`user_password` varchar(60) collate utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2 ;

--
-- Dumping data for table `administrators`
--

INSERT INTO `administrators` (`id`, `user_name`, `user_password`) VALUES
(1, 'admin', '121212121212');

Once this is done, go to the administrators table in phpmyadmin. Now empty the table. This will make it so that you can add a new username and password, now go to the admin page and create your user and password.

Finally I was getting a too many attempts to login error, to fix this error go to /catalog/admin/includes/login.php

Change this

if ($actionRecorder->canPerform())

To this:

if ($actionRecorder->canPerform() || !tep_not_null($actionRecorder->_module))

This should fix your issues 🙂

Parse Event Time From String Javascript

I am working on some code to parse event times from messy input use strings. The idea is to find the time and output the start and end time.

I have developed some code, that needs more tweaks, but I am trying to develop it so it can look for various types of user inputs for example:

7-8am
7:00 till 8:00 p.m.
Even starts at 8:00 a.m. and ends at 7:00 p.m.

Please feel free to use the code or give suggestions on how to tweak my javascript to make faster. I am sure I over-engineered it in more than one way.


var re = /(a.m.|p.m.|pm|am)/g, // Filter By
str = "String blab la bla $22.99 event starts at 12:41 a.m. ends at 10:00 p.m. asdfasdfas"; // String To Test

var timeArray = new Array();
var timeStamp = new Array();

while ((matcher = re.exec(str)) != null) {
timeArray.push(matcher.index);
timeStamp.push(matcher[0]);
}

// Get Start And End Time
startTime = str.substring(timeArray[0] - 6, timeArray[0]);
finishTime = str.substring(timeArray[1] - 13, timeArray[1]);

if (startTime.length == 2) {
finishTime = startTime.substr(1,2);
startTime = startTime.slice(0,1);
} else {
// console.log(finishTime);
// console.log(startTime);

var matches = /(-|to|till)/g;

if (finishTime.match(matches) != null) {

var splitTime = startTime.split( matches );
var slpitTimeFinish = finishTime.split( matches );

if (timeStamp.length > 1) {
finishTime = slpitTimeFinish[2].replace(/[A-Za-z$.]/g, "");
startTime = splitTime[0].replace(/[A-Za-z$.]/g, "");
startTime = startTime.replace(/[0-9]{1,3}\s/g, "");

} else {

finishTime = slpitTimeFinish[2].replace(/[A-Za-z$.]/g, "");
startTime = slpitTimeFinish[0].replace(/[A-Za-z$.]/g, "");

var breakTime = startTime.split(':')
hours = breakTime[0].replace(/[0-9]{1,4}\s/g, "");
minutes = breakTime[1];

if (minutes == null) {
startTime = hours + ":00";
} else {
startTime = hours + ":" + minutes;
}

}

startTime = startTime.replace(/\s+/g, ''); // Remove Spaces
finishTime = finishTime.replace(/\s+/g, ''); // Remove Spaces

} else {
finishTime = finishTime.replace(/[A-Za-z$.]/g, "");
// console.log(finishTime);

var breakTime = finishTime.split(':')
hours = breakTime[0].replace(/[0-9]{1,4}\s/g, "");
minutes = breakTime[1];

if (minutes == null) {
finishTime = hours + ":00";
} else {
finishTime = hours + ":" + minutes;
}

finishTime = finishTime.replace(/\s+/g, ''); // Remove Spaces
// console.log(finishTime);

startTime = startTime.replace(/[A-Za-z$.]/g, "");

var breakTime = startTime.split(':')
hours = breakTime[0].replace(/[0-9]{1,4}\s/g, "");
minutes = breakTime[1];

if (minutes == null) {
startTime = hours + ":00";
} else {
startTime = hours + ":" + minutes;
}

startTime = startTime.replace(/\s+/g, ''); // Remove Spaces

}
}

// Get Time Stamp

if (timeStamp.length > 1) {
eventStartStamp = timeStamp[0];
eventEndStamp = timeStamp[1];
} else {
eventStartStamp = timeStamp[0];
eventEndStamp = timeStamp[0];
}

console.log ("Event Starts At "+ startTime + " " + eventStartStamp +" Ends At "+ finishTime + " " + eventEndStamp );

Magento MP Survey Change Default Page Layout

I purchased and downloaded MagePage’s MP Survey. I had a client that need more than the default Magento page and survey system. I stumbled upon MagePage.com, which developed MP Survey. This Survey is awesome and did the trick. I might do a review about it at a later date.

Anyway, I ran into an issue where the default page layout was not what I wanted. By default it was 2 column, I just wanted one. After about 30 mins of messing around I was able to make this to my 1-column layout.

Here is what you do. Go to /app/design/frontend/puroast/default/layout

There back up the file survey.xml.

Now open up and edit this file and look for the following:

Add the following right after this tag.







That should fix the issue. You can also apply this after survey_category_view and survey_index_index if you would like.

That sohuld fix it.

Best Website Design Woodland

As a developer in Northern California, I love local websites. Here is my list of the best website designs Woodland, California list. Please feel free to comment and send me your favorites. I will add them to the list.
[Read more…]