Category Archive for "Article"

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

How to use hooks (actions and filters) in wordpress and woocommerce

What are hooks? Hooks are helpful in WordPress which allow you to manipulate code without editing core files. It is used extensively used throughout WordPress and WooCommerce by developers. Two types of hook: actions and filters. Action Hooks allow you to insert custom code. Filter Hooks allow you to manipulate and return a variable. There are lot of excellent article on hooks and filters as follows: 1) https://codex.wordpress.org/Plugin_API 2) https://www.tipsandtricks-hq.com/wordpress-action-hooks-and-filter-hooks-an-introduction-4163 3) http://code.tutsplus.com/articles/the-beginners-guide-to-wordpress-actions-and-filters–wp-27373 4) http://blog.teamtreehouse.com/hooks-wordpress-actions-filters-examples Using hooks If you use a…

Read More

How to optimize files and images of website?

Optimizing Websites: Optimizing your website’s files is very important for better utilization of server resources. Even a high end server can fail to deliver the speed and performance that you look for, if the website is not optimized. Following are the steps to achieve this: Images: Always work and save your images with 72 dpi. More than this will not make any difference in quality of the picture as far as web is concerned. Save an image with text or…

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

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

How to move Magento site from subdomain to main domain?

Moving magento site from subdomain to main domain (and vice-versa) is quite easy. And you can do it by two different way and you will feel it is more easy when you go through how to do it. Process I: You need to do as per following steps to achieve this: STEP 1: Go to Magento Admin –> System –> Configurations –> Web –> Unsecure URL & Secure URL. Change both the secure URL and unsecure URL to the domain…

Read More