Category Archive for "Tutorial"

How to group Security Headers for web application using htaccess?

How to group group Security for web application using htaccess? Group Security Headers htaccess X-XSS-Protection sets the configuration for the cross-site scripting filters built into most browsers. The best configuration is “X-XSS-Protection: 1; mode=block”. X-Frame-Options tells the browser whether you want to allow your site to be framed or not. By preventing a browser from framing your site you can defend against attacks like clickjacking. X-Content-Type-Options stops a browser from trying to MIME-sniff the content type and forces it to stick with…

Read More

Get last order of an customer magento

Here is the example code by which you can get last order details into mangento of using email id. $_customer = Mage::getModel('customer/customer'); $_customer->loadByEmail('demo@demo.com'); $orders = Mage::getResourceModel('sales/order_collection') ->addFieldToSelect('*') ->addFieldToFilter('customer_id', $_customer->getId()) ->addAttributeToSort('created_at', 'DESC') ->setPageSize(1); <strong>ID</strong> echo $orders->getFirstItem()->getId(); Shashi Dhar KumarShashi Dhar Kumar Experience in Web/software development including client server and implementation using PHP, XML, MySQL and SQL Server. Experience of working on Apache, Linux projects, Javascript, Ajax, Putty, FTP, Remote Connection, XML parsing, Mod-Rewriting, Payment Gateways and shipping modules, Trouble shooting and…

Read More

How to use WooCommerce’s default price at any custom template

To use WooCommerce’s price in your custom theme template open the template file and use the following code and see the magic. Example <?php global $post, $product; ?> <span itemprop=”price” class=”price”><?php echo $product->get_price_html(); ?></span> For default price template file of woocommerece you can look at folloiwng location yourtheme/woocommerce/loop/price.php. Open the file up and see the code used for the same <?php global $product; ?> <?php if ( $price_html = $product->get_price_html() ) : ?> <span class=”price”><?php echo $price_html; ?></span> <?php endif;…

Read More

Steps To Follow When Updating WordPress

The WordPress upgrade system is improved itself from last version. However, there are some steps you can take care to ensure that your upgrades doesn’t affect anything. First and foremost, upgrades and updates should be done during your off hours i.e for off visit hours for your users. Usually this is at night, but it always depends on your site’s traffic. The key is to execute your update during a low activity time just in case something goes awry. Next,…

Read More

Remove links from myaccount in magento

The easiest way to remove any link from the My Account panel in Magento is to first copy: app/design/frontend/base/default/template/customer/account/navigation.phtml to app/design/frontend/enterprise/YOURSITE/template/customer/account/navigation.phtml Open the file and fine this line, it should be around line 34: Right below it add this: <?php $_count = count($_links); /* Add or Remove Account Left Navigation Links Here -*/ unset($_links['tags']); /* My Tags */ unset($_links['invitations']); /* My Invitations */ unset($_links['enterprise_customerbalance']); /* Store Credit */ unset($_links['OAuth Customer Tokens']); /* My Applications */ unset($_links['enterprise_reward']); /* Reward Points */…

Read More

WordPress comment form validation

Copy and paste below and see the validation in working: <style type=”text/css”> .error { font-size: 12px; padding: 0 0 5px 0; color: #FF0000; } input.error, textarea.error { background: #FFD2D2; color:#000000; } </style> <?php function comment_validation_init() { if(is_single() && comments_open() ) { ?> <script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js”></script> <script type=”text/javascript” src=”http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js”></script> <script type=”text/javascript”> jQuery(document).ready(function($) { $(‘#commentform’).validate({ rules: { author: { required: true, minlength: 2 }, email: { required: true, email: true }, comment: { required: true, minlength: 20 } }, messages: { author:…

Read More

WordPress comment form customization

Copy and Paste following into your functions.php file and see the customized form <?php function po_custom_comment_fields($fields) { //define global variable global $post; //remove defaults fields here $fields[‘url’] = ”; //begin custom fields $fields[‘firstname’] = ” . ‘<p class=”comment-form-firstname”><label for=”firstname”>’ . __( ‘First Name’ ) . ‘<span class=”required”>*</span></label>’ . ‘<input id=”firstname” name=”firstname” type=”text” value=”‘ . esc_attr( $commenter[‘firstname’] ) . ‘” size=”30″ aria-required=”true” /></p>’; $fields[‘lastname’] = ” . ‘<p class=”comment-form-lastname”><label for=”lastname”>’ . __( ‘Last Name’ ) . ‘</label>’ . ‘<input id=”lastname” name=”lastname”…

Read More

Magento redirect customer after registration

Go to customer accountcontroller find _welcomeCustomer method. file location must be like app/code/core/Mage/Customer/controllers/AccountController.php Search for protected function _successProcessRegistration(Mage_Customer_Model_Customer $customer) function at accountcontroller.php file and change following: $url = $this->_getUrl(‘*/*/index’, array(‘_secure’ => true)); to $url = Mage::getUrl(‘thank-you’, array(‘_secure’=>true)); OR Search for $successUrl = $this->_getUrl(‘*/*/index’, array(‘_secure’ => true)); replace this code with your URL $successUrl = $this->_getUrl(‘thank-you’, array(‘_secure’ => true)); And don’t forget to create Thank You Page with URL Key as thank-you or you can change with your desired url, but…

Read More

Declaration of Zend_Pdf_FileParserDataSource_File::__construct() must be compatible with Zend_Pdf_FileParserDataSource::__construct()

In one of my Magento projects, on development environment everything was working fine but when the site was live “Invoice” print in magento admin[Admin>>Sales>>Orders>>Invoice>>Open Invoice>>Click print button] was giving Fatal error: Declaration of Zend_Pdf_FileParserDataSource_File::__construct() must be compatible with Zend_Pdf_FileParserDataSource::__construct(). We though that we might have missed some file when moving to live site but ultimately we found that code base was same. After doing some research we found that it was an environment issue. On development environment we were running…

Read More

How to get minimum and maximum price of Bundled Product in Magento?

I have problem to show the EMI price for particular product in bundled product in Magento. So I have tried to go through the google and found some interesting forum post to get the bundle product’s price. <?php $product_id = YOUR_PRODUCT_ID; $bundled_product = new Mage_Catalog_Model_Product(); $bundled_product->load($product_id); $selectionCollection = $bundled_product->getTypeInstance(true)->getSelectionsCollection( $bundled_product->getTypeInstance(true)->getOptionsIds($bundled_product), $bundled_product ); $bundled_items = array(); foreach($selectionCollection as $option) { $bundled_prices[]=$option->getPrice(); } sort($bundled_prices); $minimum_price=$bundled_prices[0]; $maximum_price_tmp=array_slice($bundled_prices, -1, 1, false); $maximum_price=$maximum_price_tmp[0]; echo “Minimum Price:” . $minimum_price; echo “Maximum Price:” . $maximum_price; ?> Shashi…

Read More