Wednesday, April 02, 2014

jQuery load causes IE 10/11 to crash

If you are getting crashing errors in IE 10 and 11 that say that the domain is not responding with a button to "recover webpage".



 Look for two things, I am certain there are more out there, so feel free to let me know if you find any others.

 1. jQuery calls to the load function $('someimage').load( NEW_IMAGE_URL,function(){ });

 If you find these just replace them with a simple attr update like so
 $('someimage').attr('src', NEW_IMAGE_URL);

 2. IE has trouble with the console so make sure to remove or test the browser before using console.log();


Stumble Upon CodePyro

Monday, February 10, 2014

Virtuemart 2 - How to remove SEO Suffix from Product Details aka -detail

If your using Virtuemart 2+ it requires you to use a -detail or .html  as a suffix for product pages.  Which really sucks if you are use to using SH404sef or some other plugin that will correctly re-route your URLs and make them nice. SH404sef no longer works with Virtuemart thus we are stuck with the default router. Here is how I fixed the router.php (included at the bottom for your downloading pleasuere)


Since there is not a plugin I dove into the router.php and made some simple quick fixes to ignore the SEO_Suffix and load products.

Around line 633
Code looked for categories in the last segment

$vars['virtuemart_category_id'] = $helper->getCategoryId (end($segments) ,$helper->activeMenu->virtuemart_category_id);
    $vars['view'] = 'category' ;

Changed to
$product = $helper->getProductId($segments ,$helper->activeMenu->virtuemart_category_id);
    $vars['virtuemart_product_id'] = $product['virtuemart_product_id'];
   $vars['virtuemart_category_id'] = $product['virtuemart_category_id'];


//codepyro - removed suffix from router 
  //check if the last segment is a product. 
  //if so then load the product details page instead of category 
 if(isset($vars['virtuemart_product_id']))
  {
   $vars['view'] = 'productdetails';
  }
  else
  { 
   $vars['virtuemart_category_id'] = $helper->getCategoryId (end($segments) ,$helper->activeMenu->virtuemart_category_id);
   $vars['view'] = 'category' ;
  }

Around line 943
//codepyro hack to remove suffix  
  if($this->seo_sufix_size >0)
   $productName =  substr($productName, 0, -(int)$this->seo_sufix_size );



You can download the updated router.php for Virtuemart 2.0.26d  

upload and replace the file
/components/com_virtuemart/router.php

updated 3.14.14 - I didn't realize that the site I had made these adjustments to all of the categories were set as menu items which of course makes a big difference. Anyway the zip file has been updated with the latest router.


Stumble Upon CodePyro

Thursday, October 17, 2013

jQuery UI accordion Scroll to top

When your jquery accordion has alot of content it tends to scroll the user toward the bottom of the page. If you want to scroll back to the top of the section they opened change your js to look like-a-so.

$(".accordion").accordion({
        activate: function(event, ui){
             var scrollTop = $(".accordion").scrollTop();
             var top = $(ui.newHeader).offset().top;
          //do magic to scroll the user to the correct location
          //works in IE, firefox chrome and safari
             $("html,body").animate({ scrollTop: scrollTop + top -35 }, "fast");
            },
         heightStyle: 'content' ,
        active: false,
         
    });


Stumble Upon CodePyro

Tuesday, September 17, 2013

How to find all your missing or broken images in Virtuemart

If your store has changed servers or you are just having some file backup issues and are missing your images here is a quick script to tell you which images are broken in virtuemart. This php script could easily be modified for other websites, stores, or tables.

Just change a few variables, upload and it will list out all of your missing product photos. Even with an edit link to help you fix them faster!


 /**
Joomla 1.5 - virtuemart 1.9
lists product large images that are missing and need to be re-uploaded
Thumbnails are auto generated so its not an issue to look for them.
could be easily modified for other datbases/content i.e. categories

*/

//database variables - copy from your configuration.php
$user = '';
$db = '';
$password = '';
$host = 'localhost';
$editurl ='https://www.DOMAIN.com/administrator/index.php?page=product.product_form&limitstart=0&keyword=&product_parent_id=&option=com_virtuemart&product_id=';
 
//make sure you edit your full path here 
$filepath ='/home/DOMAIN/public_html/components/com_virtuemart/shop_image/product';

echo "file location:".$filepath."<br><br>";

if (!$link = mysql_connect($host, $user, $password)) {
    echo 'Could not connect to mysql';
    exit;
}

if (!mysql_select_db($db, $link)) {
    echo 'Could not select database';
    exit;
}
//database query for the fields we need
$sql    = 'SELECT product_id,product_full_image, product_name FROM jos_vm_product';
$result = mysql_query($sql, $link);

if (!$result) {
    echo "DB Error, could not query the database\n";
    echo 'MySQL Error: ' . mysql_error();
    exit;
}

while ($row = mysql_fetch_assoc($result)) 
{
    $filename = $filepath.'/'.$row['product_full_image']; 
    //output the file name and edit link if the file is missing  
    if(!file_exists($filename))
    { 
        echo $row['product_full_image']. ' - '.$row['product_name']  ;
        echo  ' <a href="'.$editurl.$row['product_id'] .'" target="_blank">edit</a><br>';
    }
}

mysql_free_result($result);
exit();
 


Stumble Upon CodePyro

Tuesday, July 23, 2013

How to search a wordpress database for shortcodes

MySQL can regex sweetness!

here is how to search wordpress posts for shortcodes today we are searching for the shortcode

[auction startbid:250] or [auction startbid:100] etc so we can use regex to find all the shortcodes with various amounts.

select * from wp_posts where
post_content   REGEXP  '\[auction startbid:[0-9]+\]'


Stumble Upon CodePyro

Thursday, May 02, 2013

e-Commerce PCI compliance

Merchant accounts like Authorize.net are now requiring customers to become PCI compliant for e-commerce. Even if you are using an event registration software like event espresso for wordpress you will be required to go through this process.

My advise - use a HOSTED checkout .....

There are really only 2 ways to become PCI compliant. Here are the run downs of each.

  1. Use a hosted checkout like Authorize.net SIM or Paypal Standard   Customer goes outside of the website to submit their information then gets returned to the website. This method is the most cost effective. It allows you to keep the cheaper hosting and not pay for services like security metrics.

    Here is a picture that explains it.
    http://developer.authorize.net/api/howitworks/sim/
  2. Change hosting to a Virtual Private Server or Dedicated host which is severe overkill for the online business you are running. Generally it costs between $50-$75+ for a VPS and even more for a Dedicated server.  Along with the different server we would need to purchase and install a wild card SSL for all services (email, ftp, etc) around   ~$100.

    Then once all of that is completed we run security metrics scans (these take 12ish hours) review the issues and work with the hosting support team to complete the changes. Generally there are several rounds of back and forth until its compliant. The PCI compliance scan rules to change occasionally to keep up with software updates and security holes.

 As you can see option 2 becomes expensive quickly so I wanted you to be able to make an informed decision.

The question really becomes how much does hosted checkout bother you and your customers?
And are we selling enough to make this worth while?


 Of course all of this is for the website, if you process and store credit cards in house you will need to be PCI compliant there as well.


Stumble Upon CodePyro

Tuesday, March 12, 2013

How to Show/Hide Wpcommerce Shopping Cart Widget

Using jQuery you can very quickly setup functionality to show & hide the cart widget in wpcommerce. Just add the below snippet to the wpsc-cart_widget.php in your template override file at the top. Blam, done.

 When the customer clicks on add to cart button, the widget will show and be updated with the new price. When the user clicks clear cart, it hides.

Simple. The second part automatically hides the cart when its empty. This could also be done with CSS.

<script type="text/javascript">
jQuery(function(){
    
            
        jQuery('.wpsc_buy_button').click(function(){
            jQuery('.widget_wpsc_shopping_cart').show();
        });
        jQuery('.emptycart').click(function(){
            jQuery('.widget_wpsc_shopping_cart').hide();
        });
        
})
</script>


<?php if(wpsc_cart_item_count() <= 0)
{ ?>
<script type="text/javascript">
jQuery(function(){
    
    jQuery('.widget_wpsc_shopping_cart').hide();
  
})
</script>
<?php } ?>


Stumble Upon CodePyro