Magento – Get Product View Price By JavaScript

1,use prototype overwriting Product.Options.prototype.reloadPrice

Product.Options.prototype.oldReloadPrice = Product.Options.prototype.reloadPrice;
Product.Options.prototype.reloadPrice = function(){
    this.oldReloadPrice();
    var currentPrice = howToGetThePrice();
    doSomethingWithTheCurrentPrice(currentPrice);
};

2,use jQuery get the current price by cleaning the html inside an span

function getCurrentPrice(){
    var ds = optionsPrice.priceFormat.decimalSymbol,
    gs =optionsPrice.priceFormat.groupSymbol,
    pf=optionsPrice.priceFormat.pattern;

    var price = 0;
    jQuery('#product-price-<?php echo $_product->getId() ?>_clone span')
        .html()
        .replace(new RegExp("\\"+gs,'g'),'')
        .replace(new RegExp("\\"+ds,'g'),'.')
        .sub(/([0-9\.\,]+)/,function(matches){
            price = parseFloat(matches[1]);
    });
    return price;
}

3,Update element value with this code,you can update total price with qty.

$('totalPrice').innerHTML = currentPrice * $('qty').value

Magento – Get the Total Price of items currently in the Cart

If you want to get the total price of items in your Magento cart, you can use code like this:

<?php
echo $this->helper('checkout')->formatPrice(Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal());
?>

Simple Page Peel Effect with jQuery & CSS

You have probably seen these forms of advertisings where you can peel a corner of a website and see a message underneath. It seems most are flash driven, but I decided to try it out using some simple lines of jQuery.

1. HTML – Page Peel Wireframe

The “pageflip” div will act as the container, mainly used to establish the relative positioning. Then nest the image and the span class of “msg_block” wrapped in an <a> tag.

Note – If you don’t have any conflicting absolute/relative positioning properties, you technically don’t need the “pageflip” container at all.

<div id="pageflip">
	<a href="#">
		<img src="page_flip.png" alt="" />
		<span class="msg_block">Subscribe via RSS</span>
	</a>
</div>

2. CSS – Page Peel Styles

Set the image property to a smaller size (50px by 50px) by default and set the absolute positioning to be in the top right corner. The image will be used similar to the “masking” technique in Photoshop or Flash, where it will be placed on top of the hidden message, so only a portion of the message will be shown. Check out the image below for a visual:

The actual message behind the “peeling” effect, is all within the “msg_block” class. By default, it will start at 50px by 50px, positioned on the top right corner of the page. The text-indent will shoot the text off of the page for anyone with CSS enabled.

#pageflip {
	position: relative;
}
#pageflip img {
	width: 50px; height: 52px;
	z-index: 99;
	position: absolute;
	right: 0; top: 0;
	-ms-interpolation-mode: bicubic;
}
#pageflip .msg_block {
	width: 50px; height: 50px;
	position: absolute;
	z-index: 50;
	right: 0; top: 0;
	background: url(subscribe.png) no-repeat right top;
	text-indent: -9999px;
}

Note that the “msg_block” height is off by 2px compared to the image property – this is taking in consideration of the drop shadow that the image has.

3. jQuery – Animating Page Peel

All we are doing here is expanding the image and msg_block on hover, then retracting to its default size on hover out.

$("#pageflip").hover(function() { //On hover...
	$("#pageflip img , .msg_block").stop()
		.animate({ //Animate and expand the image and the msg_block (Width + height)
			width: '307px',
			height: '319px'
		}, 500);
	} , function() {
	$("#pageflip img").stop() //On hover out, go back to original size 50x52
		.animate({
			width: '50px',
			height: '52px'
		}, 220);
	$(".msg_block").stop() //On hover out, go back to original size 50x50
		.animate({
			width: '50px',
			height: '50px'
		}, 200); //Note this one retracts a bit faster (to prevent glitching in IE)
});

15 Really Cool And Sexy Free RSS Feed Icons

We know that a cool and sexy RSS icon will attract more readers to subscribe to your blog and there are hundreds of posts around the internet discussing about free RSS feed icons. Reading these posts will consume a lot of time. So, WDB team had gone through these posts and picked 15 free RSS feed icon sets that are really cool and sexy.

1) RSS icons by sniffels [Read more...]

27+ Useful Javascript Tab Navigation Scripts

There are a lot of different ways to implement tabs in our website. I had seen pure CSS implementation, Javascript implementation such as jQuery and MooTools tabs. Recently, my client request me to add tab interface to the current theme. So, i googled the web and found a lot of free scripts to do so.  now, I am going to list down useful Javascript tabs that I found.

jQuery plugin

1) jQuery UI Tabs
jquery-ui-tabs
This tab script is built in to the jQuery UI and there are a lot of configurations. For example, you can have rotating tabs, nested tabs, and etc.

2) jQuery idTabs
jquery-idtabs
jQuery idTabs makes adding tabs into a website super simple, but it also open the door to endless possibilities.

3) Minitabs – jQuery minimalistic approach to tabs
Minitabs looks simple, but I can’t found any working demo from the website. [Read more...]

5 Extremely Simple Ways To Add Page Curl To Your Website

A lot of websites/blogs using page peel/page curl to add additional message such as advertisements at the corner. There are a lot of scripts that can achieve this function but unfortunately these scripts are not free.

Recently, 1 of my client requests me to implement page curl on his WordPress theme. So, I search through the internet and found some free and extremely simple ways to implement it.

1) Simple Page Peel Effect with jQuery and CSS by Soh Tanaka

simple-page-peel-effect-with-jquery-css
In this example, Soh Tanaka show us how to achieve the page peel effect using purely jQuery and CSS. [Read more...]

Magento Use jQuery with Prototype

General

The jQuery library, and virtually all of its plugins are constrained within the jQuery namespace. As a general rule, “global” objects are stored inside the jQuery namespace as well, so you shouldn’t get a clash between jQuery and any other library (like Prototype, MooTools, or YUI).

That said, there is one caveat: By default, jQuery uses “$” as a shortcut for “jQuery”

Overriding the $-function

However, you can override that default by calling jQuery.noConflict() at any point after jQuery and the other library have both loaded. For example:

 <html>
 <head>
   <script src="prototype.js"></script>
   <script src="jquery.js"></script>
   <script>
     jQuery.noConflict();

     // Use jQuery via jQuery(...)
     jQuery(document).ready(function(){
       jQuery("div").hide();
     });

     // Use Prototype with $(...), etc.
     $('someid').hide();
   </script>
 </head>
 <body></body>
 </html>

This will revert $ back to its original library. You’ll still be able to use “jQuery” in the rest of your application.

Additionally, there’s another option. If you want to make sure that jQuery won’t conflict with another library – but you want the benefit of a short name, you could do something like this: [Read more...]

Hide The Magento Region Field In Checkout Progress

For some country,it’s not necessary to let your customers enter a region or province in the checkout. Today, I will tell you some knowledge about Magento and Javascript.

You must have noticed that for countries where it’s required, the text input field changes into a dropdown with the available regions. Also, this dropdown is required. That’s not functionality we will change. What we will do is hide the field when it changes to a text field. Without touching one single template.

First of all, it’s useful to know how Magento determines whether the field is required or not. It simply looks up whether there are known regions for the selected country. If there are no known regions, Magento assumes the region not required. If there are, it shows a dropdown of available regions and makes the field required. So if you don’t want to show the region field for a particular country, simply remove all regions from the table directory_country_region. [Read more...]

The Way To Sort Regions Address In Magento

In Magento, we need to sort regions address,we can do this:

First,modify magento front code

Open ./app/code/core/Mage/Directory/Helper/Data.php

public function getRegionJson()
{
...
$collection = Mage::getModel('directory/region')->getResourceCollection()
->addCountryFilter($countryIds)
->load();
...
}

TO

public function getRegionJson(){
...
$collection = Mage::getModel('directory/region')->getResourceCollection()
->addCountryFilter($countryIds)
->addOrder('default_name', 'ASC')
->load();
...
}

Second,modify magento adminhtml code

Open ./app/code/core/Mage/Adminhtml/controllers/JsonController.php

public function countryRegionAction(){
...
$arrRegions = Mage::getResourceModel('directory/region_collection')
->addCountryFilter($countryId)
->load()
->toOptionArray();
...
}

To

public function countryRegionAction(){
...
$arrRegions = Mage::getResourceModel('directory/region_collection')
->addCountryFilter($countryId)
->addOrder('default_name', 'ASC')
->load()
->toOptionArray();
...
}

WordPress for Low PHP Memory Limit

Some WordPress installs run out of available PHP memory because the memory limit is set too low.
This can cause random errors or white screens that show no error at all. This is a good troubleshooting checklist for any WordPress plugin that is acting strange.

Check the PHP Memory Limit:
Install this WordPress plugin to see the PHP Memory Limit and Memory Usage in the WordPress admin dashboard:
WP-Memory-Usage

http://wordpress.org/extend/plugins/wp-memory-usage/

If the memory limit is 32M or less, try increasing it:

Memory usage is dynamic, meaning that when you are uploading images, the memory usage can easily double temporarily.

Try one of these methods for increasing the amount of memory a
PHP script may consume (most people just do #3)

1. If you have access to your PHP.ini file, edit the PHP.ini
If the memory_limit shows 32M or less, try increasing it:
memory_limit = 64M;

2. If you don’t have access to PHP.ini try adding this to an .htaccess file in the root directory of your site:
php_value memory_limit 64M

3. Try adding this line to your wp-config.php file:
define('WP_MEMORY_LIMIT', '64M');

4. Talk to your web host about their recommended solution.