simple load on the fly

showViewedPropImg: function() {
if(J.s(“.listing”).length == 0) {
return false
var a = J.s(“.listing”).eq(0).get().scrollTop;
var b = parseInt(J.s(“.listing”).eq(0).get().style.height);
J.g(“test_div”).down(“.list_li”).each(function(f, g) {
var e = g.down(“.dt_img img”).eq(0);
var d = e.attr(“src”);
if(typeof d === “undefined” || d == null || d.length == 0) {
var c = g.offset();
if((c.y – a) >= 0 && (c.y – a) <= (162 + b)) {
e.attr(“src”, e.attr(“data”)).removeAttr(“data”)

J.s(“.listing”).eq(0).on(“scroll”, function(d) {
if(J.g(this).down(“.list2”).length > 0) {
return false
if(c == 0) {
if(a) {
a = setTimeout(function() {
c = 0
}, 200);
c = 1

magento — remove h1 heading from cms page

how to remove the title that appears above the cms content of cms page? from the cms.xml layout file i found the code below:

just remove this line

<block type="core/template" name="page_content_heading" template="cms/content_heading.phtml"/>

[codesyntax lang=”xml”]

    <cms_page translate="label">
        <label>CMS Pages (All)</label>
        <reference name="content">
            <block type="core/template" name="page_content_heading" template="cms/content_heading.phtml"/>
            <block type="page/html_wrapper" name="cms.wrapper" translate="label">
                <label>CMS Content Wrapper</label>
                <action method="setElementClass"><value>std</value></action>
                <block type="cms/page" name="cms_page"/>


then the h1 title of all the cms page will go.but what if you want to do this only to some specific page?you have two choice,first,you can make use of magento layout update feature for cms page.

Goto menu CMS => Pages => Click the page you want to edit => Design => Layout Update XML

add the xml code below:
[codesyntax lang=”xml”]

 <reference name="content">
            <remove name="page_content_heading"/>


the other way is update the cms.xml file directly in your theme layout folder.

Chrome won’t allow IFRAME to load a html file via http while main page using https

i just found a weird thing that the Chrome browser don’t allow an iframe to load a http url when the current url in the addr bar begin with https.for eample,if the current page’s url is:

and it contains an iframe whose src is

then,it worked ok in Firefox browser but  the iframe break in Chrome.
after google for a while,i get some conclusion when calling a page from other domain with diff protocol,:

page – iframe – status
http – http  – allowed
http – https – allowed
https- http  – not allowed
https- https – not allowed

for more related info,please refer to the following url


WooCommerce — how to add customer VAT field for billing and admin view order page

Some payment gateway need a customer VAT field to be sent to make the payment.While i was developing pagbrasil gateway for WooCommerce, i found WooCommerce do not support to add extra field for checkout and order.

Of course, for the sake of updating WooCommerce,i can not change the WooCommerce  code directly. WooCommerce was running as a plugin upon WordPress. i just need another wordpress plugin to insert a VAT field.By the way,the payment gateway for WooCommerce was also build as a pluging for wordpress,just one thing differcence,it denpends on the WooCommerce plugin.

To learning how to develop a wordpress plugin,you need to refer to wordpress docs,there are lots tutor online.i am going to the code part of this work  — add hook and filter for checkout page and order view page :

[codesyntax lang=”php”]

//add VAT field to checkout page
function VAT_override_checkout_fields( $fields ) {
	$fields['billing']['VAT_code'] = array(
	'label'     => __('VAT', 'woocommerce'),
	'placeholder'   => _x('VAT', 'placeholder', 'woocommerce'),
	'required'  => true,
	'class'     => array('form-row-wide'),
	'clear'     => true

	return $fields;
add_filter( 'woocommerce_checkout_fields' , 'VAT_override_checkout_fields');

function VAT_custom_checkout_field_order_meta_keys( $order ) {
	echo "<span><strong>VAT:</strong>" .
	$order->VAT_code . "</span>";
add_action( 'woocommerce_admin_order_data_after_billing_address', 'VAT_custom_checkout_field_order_meta_keys' );




magento — remove “Home page” from magento cms home page

The quickest way to remove “Home page” is edit the cms home page from magento backend,and remove it from the content. you need to put a whitespace in html(&nbsp;) or you can not save it.but this way still keep the cms container html tag like:
[codesyntax lang=”html4strict”]

<div class="std"> </div>


you can remove all uneeded html tag by edit the cms.xml layout code:

[codesyntax lang=”xml”]

	    <reference name="content">
		    <remove name="cms.wrapper"/>



WooCommerce — How to clear cart content after payment

Sometimes you want to clear cart content.For example, if the customer was redirected back to your WooCommerce store after payment,you need to clear WooCommerce shopping cart to avoid dumplicated how?

global $woocommerce; $woocommerce->cart->empty_cart(); 

Keep in mind the $woocommerce is a global variable. you need to explicitly declare before you can call it in function or methods.

To clear cart only for some special page, you can detect page with function is_page()  which you can pass any page title, ID or slug.




PHP — PHP Protocol https not supported or disabled in libcurl

While i was developing WooCommerce payment module for Pagbrasil gateway,i got a curl error msg as:

PHP Protocol https not supported or disabled in libcurl

To check if https protocol was supported by the server,i created a script called a.php and put <?php phpinfo(); ?> in it.From the curl section of the phpinfo page, i found  that https protocol were not listed. so the cURL was not built with SSL support.The only way is to recompile the php.




php — how to detect spider/crawler with php

I am going to write a PHP script today that detects whether a search engine spider is crawling a page.With PHP, we can check the value of $_SERVER['HTTP_USER_AGENT'],a predefined variables which store the contents of the User-Agent: header from the current request, if there is one.

$pattern = ‘/(google|msnbot|MSNPTC|yahoo|Slurp|||DoCoMo|DoCoMo)/i’;
if ( preg_match($pattern, $_SERVER[‘HTTP_USER_AGENT’] === FALSE) { // not a spider

} else { // spider


You can find a list of search engine spiders/crawlers from

magento — translate words into other language for payment module

my new mangento payment module need multiple language support.Magento interface is translated with CSV localization files which was stored at the location of app/locale/[lang_folder],ie app/locale/en_us.OR you can use the built-in Inline translation tool which store the translation pair into’s much more convenience to translate via Csv localization files than the inline translation tool when you want to translate lots of string at a time.

First, i create an empty csv file named Mzcart_Pagbrasil.csv in app/locale/en_us/.I add a translation for test purpose:

“Powered by Pagbrasil”,”Powered by Pagbrasil—-”

Second,to make the new added csv localization file visible to magento, i need to update the config xml file of this module.add the config below to config.xml file under  config >> frontend path.


However,  the string “Powered by Pagbrasil” was not translated. I did clear the cache. After googling for a long time without any clue, i added a new string and it was translated,but the first string still not changed.

“Powered by Pagbrasil”,”Powered by Pagbrasil—-”        >>>>>>> still not translated.
“Please pay your order now”,”Please pay your order now@@@@@@@@@@@@”

what’s the problem?the problem is that php does not support utf8 with bom. a BOM-ed UTF-8 string will start with the three following bytes EF BB BF. php will treat this bytes as file content.this lead to the mismatch of the first string. you may find that all lang file provided by magento all encoded in utf8 without bom.

For more info you may refer to

magento — how to get Vat number/tax id

i am developing a new payment module under magento.Everything going through well as usual.However, this new payment module require a cutomer tax id. by default,magento didn’t show this field for customer.To make it available for all customer,log into magento backend, goto

System > Configuration > Customers > Customer Configuration > Create New Account Options [tab]

change the config of “Show VAT Number on Frontend” to “yes”.

so how to get the new added filed — customer vat number/taxt need to get billing or shipping model first.the code below as an example.

$billing  = $this->getOrder()->getBillingAddress();