How to setup W3 total cache with WooCommerce

W3 Cache Plugin configuration for work with Woocommerce

For Improve website performance we use many cache plugins but its disturbed woo-commerce functionality some time.

Like W3 Cache Plugin stop product page gallery page images slider or checkout page functions for fix these issue we should nee d to configure W3 properly .Following things need to configure.

1 – You must add _wc_session_ to the “Ignored Query Strings” option in W3TC settings.

WP-admin go to Performance > Database Cache and add _wc_session_ to the Ignored query stems: Textarea box

2 – Add mfunc to the list of Ignored Comment Stems:

According wootheme guidelines for WooCommerce Cache Ensure you add ‘mfunc’ to the ‘Ignored comment stems’ option in the Minify settings.

Go to Performance > Minify, add mfunc to the list of Ignored comment stems:

3 – Exclude WooCommerce specific pages from the W3 Total cache

To exclude following WooCommerce pages from Cache

Add cart, checkout, shop, /shop* etc in Performance > Page Cache – Never cache the following pages text-area box.

Contact Form 7 Special Mail Tags

There may be times when you need more information than just the submitter’s input through contact form fields. For example, you may need to know the submitter’s IP address for security reasons. For such purposes, special mail-tags can be very helpful.

Unlike other mail-tags, special mail-tags are independent from form fields or the submitter’s input. You can place these special mail-tags anywhere mail-tags are allowed to be used, such as in the message body or other mail fields.

Special Mail Tags for Submissions

1
[_remote_ip]

 — This tag is replaced by the submitter’s IP address.

1
[_user_agent]

 — This tag is replaced by the submitter’s user agent (browser) information.

1
[_url]

 — This tag is replaced by the URL of the page in which the contact form is placed.

1
[_date]

 — This tag is replaced by the date of the submission.

1
[_time]

 — This tag is replaced by the time of the submission.

1
[_invalid_fields]

 — This tag is replaced by the number of form fields with invalid input.

1
[_serial_number]

 — This tag is replaced by a numeric string whose value increments, so this tag can work as the serial number of each submission.

How to Install Python & Django on Windows

Install Python, Virtual Environments, Django on Windows Using PIP (Python Package Installer) and Windows Powershell We can setup python virtual environments and Django on windows PC.

1. Download from Lates python version for windows from that url. https://www.python.org/downloads/

2. Run python .exe installable  file and install python.
3. Verify Python Installed in Powershell    

    1. Search/Open Windows Powershell
    2. Type 
      1
      python -V

       and hit enter. Does the following show up?:

    3. Verify pip by entering:    pip freeze

4. Update Powershell Settings:

You should only have to do this 1 time, if done correctly. 1. Search Windows Powershell (a search is important) 2. Right click, select “Run as Administrator”; cofirm security pop-up if needed 3. Enter:

1
Set-ExecutionPolicy Unrestricted

5. Create Dev Folder (directory):

Open Windows Powershell (not needed to run as Admin now)
Type:

1
2
C:\ > cd ~/
C:\ > mkdir Dev

6. Install Virtualenv:

Going forward, whenever you see > or $ before code, that means you should be working in the Windows Powershell (or Command Prompt if you don’t have Windows Powershell)

To install a virtual environment:

1
 pip install virtualenv

Verify:

1
 pip freeze

virtualenv==15.1.0

6. Create a Virtualenv:

Navigate to Dev:

1
 > cd ~/Dev

Make virtualenv parent directory:

1
2
3
4
 > mkdir cfehome
&gt; cd cfehome <code>
Create virtualenv
<code> &gt; virtualenv .

Note, if you have two versions of python installed you may have to do this:

1
 &gt; virtualenv -p python3 .

Activate your environment:

1
2
3
&gt; cd \path\to\your\virtualen\env\
&gt; cd ~\Dev\cfehome
&gt; .\Scripts\activate

6.Now install any Python Package:

1
2
3
&gt; cd ~\Dev\cfehome
&gt; .\Scripts\activate
(cfehome) &gt; pip install django==1.11.5

7.Now run python django on server:

1
2
3
4
mkdir src
cd src
django-admin.py startproject cfehome .
python manage.py runserver

Now check server url in browser .

Fetching Data From a PHP Server in AngularJS

AngularJS is perfect for displaying data from a Database. Just make sure the data is in JSON format.

Fetching Data From a PHP Server Running MySQL

Server Code Examples
The following section is a listing of the server code used to fetch SQL data.

Cross-Site HTTP Requests
A request for data from a different server (other than the requesting page), are called cross-site HTTP requests.

Cross-site requests are common on the web. Many pages load CSS, images, and scripts from different servers.

In modern browsers, cross-site HTTP requests from scripts are restricted to same site for security reasons.

The following line, in our PHP examples, has been added to allow cross-site access.
Server Code PHP and MySQL

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
$conn = new mysqli("myServer", "myUser", "myPassword", "Northwind");
$result = $conn-&gt;query("SELECT CompanyName, City, Country FROM Customers");

while($rs = $result-&gt;fetch_array(MYSQLI_ASSOC)) {
if ($outp != "") {$outp .= ",";}
$outp .= '{"Name":"'  . $rs["CompanyName"] . '",';
$outp .= '"City":"'   . $rs["City"]        . '",';
$outp .= '"Country":"'. $rs["Country"]     . '"}';
}
$outp ='{"records":['.$outp.']}';
$conn-&gt;close();

echo($outp);

Html code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<html>
<style>
table, th, td {
  border: 1px solid grey;
  border-collapse: collapse;
  padding: 5px;
}
table tr:nth-child(odd) {
  background-color: #f1f1f1;
}
table tr:nth-child(even) {
  background-color: #ffffff;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>

<div ng-app="myApp" ng-controller="customersCtrl">

<table>
  <tr ng-repeat="x in names">
    <td>{{ x.Name }}</td>
    <td>{{ x.Country }}</td>
  </tr>
</table>

</div>

<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
    $http.get("customers_sql.aspx")
    .then(function (response) {$scope.names = response.data.records;});
});
</script>

</body>
</html>

How to Embed a YouTube Video with Autoplay and Sound Muted

This tutorial explains how you can embed a YouTube video that will automatically play when the web page is loaded but with muted audio by Embed code.

EMBED YOUTUBE PLAYER WITH AUTOPLAY AND SOUND MUTED

This is easy. Go the YouTube video page and note down the ID of the video from the URL. For instance, if the YouTube video link is http://youtube.com/watch?v=xyz-123, the video id is xyz-123. Once you have the ID, all you have to do is replace YOUR_VIDEO_ID in the following code with that string.

We should need to add two query string in embed video url for autoplay and mute.

&mute=1   For sound mute

&amp;autoplay=1   For autoplay

 

1
<iframe src="https://www.youtube.com/embed/VIDEO_ID?rel=0&mute=1&amp;autoplay=1" frameborder="0" allowfullscreen=""></iframe>

How to get Page url with java script

JavaScript Window Location

The window.location object can be used to get the current page address (URL) and to redirect the browser to a new page.
Some examples:

window.location.href returns the href (URL) of the current page
window.location.hostname returns the domain name of the web host
window.location.pathname returns the path and filename of the current page
window.location.protocol returns the web protocol used (http: or https:)
window.location.assign loads a new document

1
2
3
4
5
6
7
8
if (window.location.pathname == '/xyz.php') {
$("#button1").click(function(){'
//do something
})
}else if(window.location.pathname == '/xyz1.php'){
$("#mytextfield").hover(){
alert('message');
}

jQuery smooth scroll to anchor #id

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!-- SMOOTH SCROLL -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(function() {
  $('a[href*=#]:not([href=#])').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
      var target = $(this.hash);
      target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
      if (target.length) {
        $('html,body').animate({
          scrollTop: target.offset().top-150
        }, 1000);
        return false;
      }
    }
  });
});
</script>
<!-- End of SMOOTH SCROLL -->

How to increase wp memory limit and PHP Max Input Vars in wordpress

Increasing memory allocated to PHP:

 

Just add this line into wp-config.php file:

1
define( 'WP_MEMORY_LIMIT', '64M' );

Add this code into htaccess file:

1
php_value memory_limit 128M

max_input_vars

The most common issue stems from the

1
max_input_vars

PHP directive, which was introduced in PHP 5.3.9. By default, max_input_vars is set to 1000, which can easily be reached with the WordPress menu system, since each menu item sends about 12 variables per item.

Solution

The solution is to simply configure the

1
max_input_vars

so that it is large enough to handle the number of variables being sent by WordPress to save your menu.

php.ini

If you have access to your

1
php.ini

, you can just add this directive (or change the value of the existing directive) to includes your max input variables:

1
max_input_vars = 3000;

If you don’t have access to this file (as with many shared hosts), you may need to contact your host to increase this limit.

.htaccess

Alternatively, you can try placing this in your

1
.htaccess

. This won’t work on some servers, so your mileage may vary.

1
php_value max_input_vars 3000

Cordova Command-Line Interface

The Command-Line Interface

This guide shows you how to create applications and deploy them to various native mobile platforms using the cordova command-line interface (CLI). This tool allows you to create new projects, build them on different platforms, and run on real devices or within emulators. The CLI is the main tool to use for the cross-platform workflow (See the Overview for a description of the various workflows.) However, you can also use the CLI to initialize project code, after which you use various platforms’ SDKs and shell tools for continued development.

Prerequisites

Before running any command-line tools, you need to install SDKs for each platform you wish to target. (See the Platform Guides for more details.)
To add support or rebuild a project for any platform, you need to run the command-line interface from the same machine that supports the platform’s SDK. The CLI supports the following combinations:

  • iOS (Mac)
  • Amazon Fire OS (Mac, Linux, Windows)
  • Android (Mac, Linux)
  • BlackBerry 10 (Mac, Linux, Windows)
  • Windows Phone 7 (Windows)
  • Windows Phone 8 (Windows)
  • Windows 8 (Windows)
  • Firefox OS (Mac, Linux, Windows)

On the Mac, the command-line is available via the Terminal application. On the PC, it’s available as Command Prompt under Accessories.
The more likely it is that you run the CLI from different machines, the more it makes sense to maintain a remote source code repository, whose assets you pull down to local working directories.
To install the cordova command-line tool, follow these steps:

1. Download and install Node.js. Following installation, you should be able to invoke node or npm on your command line.
2. Install the cordova utility. In Unix, prefixing the additional sudo command may be necessary to install development utilities in otherwise restricted directories:

Read more »

how to get skin url, get media url, get base url, get store url in magento

Magento Mage Core, Admin Static Blocks, or Phtml edits are usually includes getting url path such images, javascript, base url, media and store url. There are different ways to retrieve mentioned URL paths depending on where section you’re editing.

To Retrieve URL path in STATIC BLOCK

To get SKIN URL

{{skin url=’images/sampleimage.jpg’}}

To get Media URL

{{media url=’/sampleimage.jpg’}}

To get Store URL

{{store url=’mypage.html’}}

To get Base URL

{{base url=’yourstore/mypage.html’}}

TO Retrieve URL path in PHTML

Note: In editing PHTML don’t forget to enclode the following code with PHP tag
Not secure Skin URL:

 

Secure Skin URL

 

Get Current URL

$current_url = Mage::helper(‘core/url’)->getCurrentUrl();

Get Home URL

$home_url = Mage::helper(‘core/url’)->getHomeUrl();

Get Magento Media Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);

Get Magento Media Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);

Get Magento Skin Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);

Get Magento Store Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);

Get Magento Js Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);