Category Archive for "Open-Source"

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…

Like to share it
Read More

Remove decimal value from price of product in magento

Remove decimal value product price Magento Price of product is : 135.00USD => 135USD How to remove decimal value from product price in magento? In order to remove decimal digits in price of product magento, we need to custom some code :Go to this file : app/code/core/Mage/Directory/Model/Currency.php Open app/code/core/Mage/Directory/Model/Currency.php Find the following code on line no 195 :- Find this code: public function format($price, $options=array(), $includeContainer = true, $addBrackets = false) { return $this->formatPrecision($price, 2, $options, $includeContainer, $addBrackets); } and…

Like to share it
Read More

How to hide product attributes with no value in Magento

As a working consultant on Magento Project I come across that different product type to have different product attributes. This means that every product will have more than 20 options and sometimes all option don’t apply to certain products. For instance a projector and laptop have different kind of product attributes like “Front Camera” in laptop is necessary to show as an product attribute, but into project it should not. Because the store uses the same attribute sets for each…

Like to share it
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…

Like to share it
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;…

Like to share it
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…

Like to share it
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…

Like to share it
Read More

How to ensure your WordPress site’s security?

What is Security? Fundamentally, security is not about perfectly secure systems. Such a thing might well be impractical, or impossible to find and/or maintain. A secure server protects the privacy, integrity, and availability of the resources under the server administrator’s control. Your website can never be 100% secure. Hackers are always trying new things and discovering new vulnerabilities to exploit. The online world changes quickly and the same is true of security. Good security is about minimizing risk. If anybody…

Like to share it
Read More

How you can add Cron Job at Cpanel?

Execute Cron Job in Cpanel using PHP script. In cpanel the following will also work: Execute code every minute(Server Time) using following code: * * * * * php -q /home/serverpath/file.php Execute code every five minute(Server Time) using following code: */5 * * * * php -q /home/serverpath/file.php Execute code twice an hour(Server Time) using following code: 0,30 * * * * php -q /home/serverpath/file.php Execute code once an hour(Server Time) using following code: 0 * * * * php…

Like to share it
Read More

How to add custom post type in wordpress

Open “function.php” add the following code to add new custom post type : <?php add_action(‘init’, ‘featured_post_register’); function featured_post_register() { $labels = array( ‘name’ => _x(‘Featured Posts’, ‘post type general name’), ‘singular_name’ => _x(‘Featured Posts’, ‘post type singular name’), ‘add_new’ => _x(‘Add New’, ‘featured posts’), ‘add_new_item’ => __(‘Add New Featured Posts’), ‘edit_item’ => __(‘Edit Featured Posts’), ‘new_item’ => __(‘New Featured Posts’), ‘view_item’ => __(‘View Featured Posts’), ‘parent_item_colon’ => ” ); $args = array( ‘labels’ => $labels, ‘public’ => true, ‘publicly_queryable’ =>…

Like to share it
Read More