Woocommerce Change Text on Checkout Page | Quick Tutorial

Woocommerce Change Text on Checkout Page tutorial will cover only how to change the texts in the woocommerce checkout page using a function. Manually changing it on the wocoommerce core files is not advisable.

One of my clients asked me to remove the words “have read and” from the Woocommerce checkout page : “I have read and accept the terms & conditions“.

woocommerce change text on checkout page
Woocommerce Change Text on Checkout Page | Radiobox

 

The first step that was on my mind is using the translation function in wordpress and it should remove the 3 words by replacing the whole text statement.

I am going to change the texts using the Gettext  filter hook in WordPress. I copied the whole texts and created a function, this is the one below:


function woo_checkout_texts( $changed_text, $text, $domain ) {
 if ( $changed_text == 'I have read and accept the terms & conditions' ){
 $changed_text = 'I accept the terms & conditions';
 }
 return $changed_text;
}
add_filter( 'gettext', 'woo_checkout_texts', 20, 3 );

 

But the when I checked the website’s checkout page, it doesn’t change. I forgot that the link was composed of an anchor tag. Therefore when you translate something you should also add the static markup that is between the text you are translating/changing.

 

So how?

I looked into the woocommerce plugin folder and find the file containing the texts in it that we can copy and modify into our functions.php file. Yes, we just copy and modify it into our functions.php file.

Any changes within the plugins file is not a good practice, in a plugin update it will get removed because it will be overridden with the new updated file code.

So to make it professional as possible, I’ve search files inside the woocommerce plugin with a word “checkout”. There, I found the terms.php file. I’ve open it on my editor and found this content.

woocommerce change text on checkout page
Woocommerce Change Text on Checkout Page | Terms

Now I’ve got the idea of how to change texts on the checkout page in woocommerce.

I’ve copied the text and pasted it on functions.php with my function. I’ve copied it again as a translated text by removing the words’ “have read and”.

This is final function below:


function woo_checkout_texts( $changed_text, $text, $domain ) {
 if ( $changed_text == 'I&rsquo;ve read and accept the <a href="%s" target="_blank">terms &amp; conditions</a>' ){
 $changed_text = 'I accept the <a href="%s" target="_blank">terms &amp; conditions</a>';
 }
 return $changed_text;
}
add_filter( 'gettext', 'woo_checkout_texts', 20, 3 );

I’ve checked the checkout page, done, now it is finally translated.

This is how you customize the checkout page texts in woocommerce.

 

CSS Hover Effects | Fade in Text with Background Source Code

Fade in Text with Background Hover

This video is going to show you how to create a CSS Fade in text with background Hover effect. An image is covered with a solid color fades in with a text when a user hovers it.

The HTML

<!DOCTYPE html>
<html>
<head>
</head>
<body>

<div class="wrapper">
 <img src="animal.jpeg">
 
<div class="overlay">

<div class="content">Fade In<span>Fade In text</span></div>

 </div>

</div>


</body>
</html>

The CSS


.wrapper {
font-family: sans-serif;
width: 80%;
margin: 0 auto;
position: relative;
}

img {
display: block;
width: 100%;
height: auto;
}
.content {
position: absolute;
top: 45%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
color: #fff;
text-transform: uppercase;
font-size: 60px;
}

.content span{
font-size: 24px;
display: block
}

.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background-color: #ff771d;
}

.wrapper:hover .overlay {
opacity: 1;
}

Fade In Background Opacity(transparent) Hover

The HTML


<!DOCTYPE html>
<html>
<head>
<title>CSS hover effects: Fade In Background opacity</title>
</head>

<body>



<div class="wrapper">
<img src="highland.jpeg">


<div class="overlay">

<div class="content">
the title <a>read more</a>
</div>


</div>


</div>



</body>
</html>

The CSS


.wrapper{
font-family:sans-serif;
width: 80%;
margin: 0 auto;
position:relative;
}
img{
opacity: 1;
display: block;
width:100%;
height: auto;
transition: .5s ease;
}
.content{
position: absolute;
top:45%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
text-transform: uppercase;
font-size: 60px;
color:#fff;
white-space: nowrap;
overflow: hidden
}
.content a{
font-size: 24px;
display: block;
background-color: #ff771d;
text-align: center;
padding: 10px;
cursor: pointer
}
.overlay{
opacity: 0
}
.wrapper:hover img{
opacity: .5
}
.wrapper:hover .overlay{
opacity: 1
}

How to Center an Image in CSS Very Easily

center image in css

There are few pointers to center an image in CSS.

 

  • First, make sure that the parent element of the image has its width set.
  • Second, the image should not be wider than its parent element, that’s pretty obvious.

 

See also:  How To Center A Div Inside A Div Easily

 

Center and Image in CSS horizontally

Images are the same as divs, you can use the text-align into its parent element but not the margin: 0 auto alone on the image.


To center image in div, set a width of the div then add margin:0 auto and display: block into the image in CSS.

 

The HTML code:


<div class=wrapper>
 <img src="http://www.22bulbjungle.com/wp-content/uploads/2017/04/rabbit_in_hand.jpg" />
</div>


 

The CSS styles:

.wrapper{
 width: 100%;
 height: 300px; 
 border: 2px solid #93c504;
}
img{
 max-width: 250px;
 display: block;
 margin: 0 auto
}

 

This will result into an image centered horizontally:

center-image_margin_0_auto

 

See the jsfiddle:


 

Make sure you have a smaller image width than the parent element.

The margin’s first value 0 was for the top and bottom margin. While the second is for left and right margin.

 

You can also set margin-left: auto and margin-right: auto on the image in CSS.

 

Center an Image in CSS horizontally and vertically

 

We will going to use the span element to guide our image  making it center. Setting an image with margin and text-alignment could not make our image center align.

 

The HTML code:


<div class=wrapper>
 <span class="for-image"></span>
 <img src="http://www.22bulbjungle.com/wp-content/uploads/2017/04/rabbit_in_hand.jpg" />
</div>

 

The CSS styles:


.wrapper {
  width: 100%;
  height: 300px; 
  border: 2px solid #93c504;
  text-align: center
}

.for-image {
  height: 100%;
  display: inline-block;
  vertical-align: middle
}

img {
  max-width: 200px;
  height: auto;
  background: #3A6F9A;
  vertical-align: middle
}

center-image_margin_auto

Responsive design images

Creating a responsive design image is very useful for mobile devices.

Responsive image will automatically scale down and adjust to the width of the device.

To create a responsive design image, you just set a max-width: 100%; and height: auto; into the images.

 


The max-width: 100%; means the image’s width will cover all its parent’s width. You can also set a natural image width(full resolution width of the image) to the max-width property so it will not be basing upon its parent element’s width.

The height: auto; makes the image height and width proportional. As a result, it would not stretch.

 

What happens if you will not set a height: auto; is, the image’s original height will still be the same while the width is scaling according to the device’s width, so it will be non-proportional.


Background Image Color Overlay | Create a Filter Look with CSS

css_color_filter_overlay

To add a color overlay to the background image, I am going to use CSS.

 

First of all, adding a CSS background image color overlay is the most dynamic way of creating tinted web page images. It became popular to many websites which appear in homepage as banners.

 

Example:

css-background-image-color-overlay2

 

The great thing about adding background image color overlay is that you can just change any image (normal image without filter) dynamically and publish it on your website with filter, thanks to CSS.

 

So, how to do it?

 

Watch the video or continue reading.

 

 

See also:

 

Add a background property

(Yes not a background-image or background-color).

 

Within the background property, I add a linear gradient and a URL to the image.  I am using a linear-gradient background with transparency.

 

 background:
   linear-gradient(
   rgba (255, 255, 255, 0.5), 
   rgba (255, 255, 255, 0.5)
   ), 
   url(image.jpg)

 

In one CSS property, I need to set two backgrounds. The first one is the linear-gradient color and the second is the actual image.

 

Because I need to add transparency for the background color opacity, I will define RGBA inside the linear gradient.

 

Example:

linear-gradient(
   rgba (255, 255, 255, 0.5), 
   rgba (255, 255, 255, 0.5)
   );

 

The RGBA is an RGB color with an alpha channel. The alpha channel must be set between 0.0 to 1.0. It is the last parameter of the RGBA. The RGBA parameters are composed of red, green, blue, alpha.

Example: rgba (255, 255, 255, 0.5)

 

How to choose and get a color?

 

To make it easier for you to choose the color, create your web page document copying the code from here. Open it in the browser.

 

Developer tool in your browser is your friend. Right-click and inspect your web page (or CTRL+SHIFT+I).

 

On your div with the background style, click on the colored square or circle and a color picker will appear. Choose your color by dragging into the palette.

 

color-box-22bulbjungle-css-background-image-color-overlay2

 

Change the opacity of the color you’ve picked, that is important so we can mimic the overlay or color filter effect in photoshop with our background image.

 

You can also use CSS Gradient Generator from sites like colorzillacssmatic, or cssportal.

 

See the jsfiddle:

Use the background-blend-mode

Are you familiar with Photoshop blend modes?

 

Well, I can also blend our background but with CSS.

 

I can also use the linear-gradient without the transparency and add a background-blend-mode: soft-light;

 

The CSS code should look like this:


.block {
 height: 350px;
 background: linear-gradient(yellow, yellow), url(image.jpg);
 background-size: cover;
 text-align: center;
 background-blend-mode: soft-light;
}

 

As a result, the image and the color blended together in soft-light. Unlike the other way in which I can adjust the opacity.




 

You can experiment by adding different value into the background-blend-mode property.

 

background-blend-mode values include:

  • normal
  • multiply
  • screen
  • overlay
  • darken
  • lighten
  • color-dodge
  • saturation
  • color
  • luminosity

 

CSS Background image color overlay in hover

 

Add a background image color overlay if the user hovers over the image.

 

 

In conclusion, adding the color filter effect can be done in two ways. The first is through a background property with the linear gradient and image url.

 

The other is to add a solid color within the parameter of linear-gradient and add the background-blend-mode property.

 

Creating a Hero Image with color filter overlay on hover

 

Hero image is a large website banner image. It is composed of the background image, texts and even a button.

 

Learn how to create your hero image with CSS background image color overlay by watching the video below:

You can use either of the two techniques to add the effect into your CSS background image.

 

Disable Right Click with Javascript

Disable right click with javascript

Disable right click to prevent end users the capabilities to inspect, print, or copy.

 

Note: you can print a webpage by heading over to the browser options or a shortcut varying from different browser types.

 

Disable right click with javascript

Disable right click and content copying

 

Preventing the user from copying your content inside your webpage was also one of the reasons, but it’s useless when you can manage to use the shortcut key Ctrl+C to copy. Using CSS is a better way to prevent the user from copying.

 

Try to look at the code below and right-click on the result section.

 

 

Find out how to disable a user from copying your texts using CSS:

 

Just make sure you also disable the right click function so a user cannot inspect through right-clicking.

 

Disable right click on images

 

The major reason to disable the right click is to prevent the users from inspecting your code. Preventing them also disable them to download images.

 

Try to look at the code below and see how the JavaScript function is used to disable the right click into images.

 

Did you know, a user can also get your images through downloading the whole web document?

 

The document will have the webpage’s HTML, CSS, JS, images and other files that can be viewed without an internet connection. Images inside the downloaded document were the actual image from a live web page.

 

Another thing, a user can also use the page info feature in firefox browser to find the image by going to the media tab and clicking on the links to preview the image.



 

Without looking at the image quality, a screenshot is also another way to get the image.

 

The only problem is, a user can disable the JavaScript in the browser. Hence, the script added would not run.

 

A user can disable JavaScript in Chrome by going to this path: chrome://settings/content .

chrome_content_settings

Under JavaScript, there are two radio options allow and disallow JavaScript.

 

In Mozilla Firefox, the user can disable JavaScript by going to this path: about:config within the browser.

firefox_about_config

 

Next, click the button saying “I accept the risk”. Search for JavaScript, then right-click and click on toggle.

 

This will turn JavaScript into false indicates that it is now disabled.

 

I would not recommend disabling right-click function but if for some reasons / for debugging purposes etc or even a first steps to protect your own copyright images.

 

How To Disable Text Selection With CSS User Select

css user select

By default, texts on any web page can be highlighted and copied. Disable the highlight function also disables someone to copy the texts in the document. Using CSS user select makes the texts unselectable.

 

If for some reasons, you do not want your texts inside the button or paragraph to highlighted. CSS user select style attribute might help you.

 

So how to disable text selection with CSS user select?

 

Learn how by watching this video or you can continue reading.

 

See more amazing CSS videos in youtube: Garnatti one

 

Target an element and add the following styles

 

-webkit-touch-callout: none;
-webkit-user-select:none;
-khtml-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;

It is self-explanatory that these styles disable the text selection.
Try to select the sentence demo below. The sentence was added with the CSS user select styles.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit.

 

Notice that you cannot highlight the sentence above means the styles that added worked.

 

The-webkit-touch-callout attribute targets the ios safari browser, -webkit-user-select targets Chrome, Opera and Safari browsers, -khtml-user-select targets Konqueror, -moz-user-select targets Mozilla firefox and -ms-user-select:none targets internet explorer.

 

You can use this technique.

 

Prevent people from copying your content. Unfortunately, it is useless if people inspect your code from the browser. They can just copy the content within the source code.

 

Do not want somebody to copy your contents? The better way is to disable the right-click mouse function.

 

How To Link CSS To HTML | Step By Step

how to link css to html

There are three ways to link css to html: inline, internal and external stylesheets.
Here is the video you can watch to better see how the different stylesheets are implemented or continue reading for a detailed explanation.

 

See more amazing CSS videos in youtube: Garnatti one

 

1. Inline

Use inline style if you want to add a style uniquely to an element. Just add style attribute to the chosen element/tag and then add the style attribute and value.
Example:

<h1 style=”font-family:arial; color:red”>Hello World !</h1>

 

2. Internal

If you want your css to be within the same page as your webpage then internal css stylesheet is for you. Inside the head section add an opening and closing style tag. In the opening style element, add type attribute equals to ”text/css” .

 

<style type=”text/css”> </style>

 

Between your opening and closing style tags add desired styling attribute by targeting elements.
Example:

<style type=”text/css”> h1{
	font-family: ‘arial’;
	color: red;
} </style>

 

3. External

If you want your files to be organized then use external css stylesheet. Create a css file and save(the same level with the html file).

 

Name your css file whatever you want I name mine as style.css. Inside in your head section in html add a link tag to link our css file.
Example:

<link rel=”stylesheet” type=”text/css” href=”style.css”>

We can now add styles inside our style.css file just like the internal css styles above but without the open and closing style tags.

How To Center A Div Inside A Div Easily

how-to-center-a-div-inside-a-div-tutorial

Why do we center a div inside a div element? Notice most of any website’s main content block always on the middle or a picture perfectly aligned on the middle.

 

There are a lot of ways to center a div inside a div. In this tutorial I am going to show you two different ways to center a div element inside another.


These two videos might help you.

See also:  Center Align Texts in Vertical Position
Continue reading below if you don’t want to watch the video.

 

Margin to center a div

Make the margin of the child div (the div inside the div) set to zero and auto.

 

.child-div{
  margin: 0 auto;
}

Notice the code above we have set the first value to zero. The zero value is the margin from the top and also from the bottom of the div. In the second value, we have not set a numeric value but an auto which makes the div go in the middle horizontally. It is the margin from left and right of the div.

 

Note: Make sure to set a width in your child and parent div for this to work. The parent div should have a greater width obviously.

 

Text Align to center a div

.parent-div{
  text-align: center;
}

Telling the parent div to make its child’s text elements to center also makes the child div to center horizontally. As a result the texts inside our child div are also centered. Therefore, the last thing we need to do is to keep the text aligned to the left.

 

The solution, we should target the child div and add a CSS style but this time text alignment to the left or wherever you prefer.

 

how to center a div inside a div

 

.child-div{
  text-align:left;
}

See more amazing CSS videos in youtube: Garnatti one

 

In conclusion, the two CSS styling techniques are both great methods to use to align a child div element in the middle. The margin attribute is better than the other since it will make your code lesser and simpler.