WooCommerce is a very popular, highly versatile, and, I think, widely used eCommerce plugin for WordPress. This plugin offers a range of advanced features that ultimately help enhance an online store’s functionality. Visual elements are crucial for an eCommerce store because a better user experience is highly dependent on them. One such element in WooCommerce is the magnifying glass icon, which is mainly used for zooming in on the product image on the product page. This functionality helps and enables a customer to zoom and examine a product carefully before finally making a purchasing decision, and it undoubtedly improves their shopping experience, right?
Although this is an awesome feature in WooCommerce, you might want to customize or change the magnifying glass icon to align with your existing design or branding. No problem. In this detailed guide, I’ll show you how to change WooCommerce magnifying glass icon, provide insights from Stack Overflow (a Q&A platform for programmers and developers), and give practical examples along with secret tips and tricks. So, why wait? Let’s get started!
What is a WooCommerce Magnifying Glass Icon?
The WooCommerce magnifying glass is a part of the product image gallery, and this is very important for users. Why? Because people can zoom in and examine a product in more detail using this option. This feature enables them to examine the product more closely and helps them make their buying decision.
The default WooCommerce zoom icon may not match the current website aesthetics or design preferences. That’s why there are different ways to change it to match the existing design.
Do You Need To Change the Magnifying Glass Icon?
Do you really need to Change WooCommerce Magnifying Glass Icon? Yes, but only when you need to maintain your brand consistency. If a site’s design and branding are consistent, it looks good, and that’s why, to be consistent, you might need to change the default magnifying glass.
A custom magnifying glass consistent with your branding can also be more effective and may improve the user experience. User experience is a crucial factor in converting a visitor into a customer. So, to improve the user experience, you might need to change the icon.
Another problem you may face is that the default icon may not fit well with your WordPress theme, and you need to change the icon immediately.
So, these are the main reasons behind it. Let’s not talk anymore and start learning some easy and effective methods to change the magnifying glass icon of the WooCommerce store.
How To Enhance Your WooCommerce Store with a Custom Magnifying Glass Icon
There are many different ways you can follow to change the icon. It mainly depends on the level of customization you want in your store. Basically there are three methods used in changing the icon and they are:
- Using custom CSS
- Modifying theme files
- Use a plugin
Let’s see all these three methods and how they work and you can use them to change the magnifying glass on your store.
Method 1: Use Custom CSS
If you don’t want to edit themes or WooCommerce core files, then this method is the easiest way, I think. You can easily change the appearance of the magnifying glass icon by this method without any changes to the functionality.
Now, let’s see the steps.
- First, Identify the CSS Class: Generally, this is identified and represented by the ‘.woocommerce-product-gallery__trigger’ class.
- Launch WordPress Customizer: Go to your WordPress main dashboard and navigate to Appearance > Customize > Additional CSS.
Now you can add these CSS code there:
.woocommerce-product-gallery__image::before {
content: '';
background-image: url('URL_OF_YOUR_NEW_ICON');
background-size: contain;
display: block;
width: 24px; /* Set width */
height: 24px; /* Set height */
position: absolute; /* Position it appropriately */
}
Now you have to replace ‘URL_OF_YOUR_NEW_ICON’ with the correct URL of your new icon. You can also adjust the width and height as necessary for your design.
- Save the Changes: Click on ‘Publish’ to save the changes you have made.
Pros of This Method:
- You do not need to customize any theme files.
- You won’t need to modify any core WooCommerce files, so there is no chance of breaking something.
Cons of This Method:
- This method will only allow you to change the appearance, not the functionality, of the zoom feature.
Method 2: Use a Child Theme and Modify Theme Files:
If you want to change the zoom feature along with its behavior, you need to use a child theme and modify the theme files. You have to use a child theme here because if the theme is updated, your changes will not be overwritten and will keep the features as you set them before.
So, how do you do that? Let’s see.
1. Create and Use a Child Theme: If you don’t have a child theme in your eCommerce store, you need to create a child theme for it. To do that, you need to copy your parent theme’s files into a new folder and add a style.css and functions.php file.
2. Find the WooCommerce Product Gallery Template: Template files are used by WooCommerce product pages to successfully render the gallery and zoom functionality. To locate the required template, navigate to /wp-content/plugins/woocommerce/templates/single-product/. Here, find the product-image.php file.
3. Edit the Template: Now you need to copy the relevant WooCommerce template file into your child theme’s folder, which is /wp-content/themes/your-child-theme/woocommerce/single-product/.
Open the file and find the code responsible for the magnifying glass icon. This may look like the example given below:
<a href="#" class="woocommerce-product-gallery__trigger"> <i class="fa fa-search-plus"></i> </a>
4. Change the Icon: Now replace the icon with your chosen icon. For example, you can use an SVG image file or a Font Awesome icon:
<a href="#" class="woocommerce-product-gallery__trigger"> <img src="path-to-your-new-icon.svg" alt="Zoom"> </a>
5. Save the Changes: Now save the file and upload it to your child theme.
Pros of This Method:
- By using this method, you will have full control over customization of both the icon and the zoom functionality.
- You don’t have to rely on a third-party plugin, and your site will be speed optimized, which is crucial for better user experience and SEO.
Cons of This Method:
- You will need proper technical knowledge of PHP and WooCommerce file structure.
- WooCommerce updates may require you to update your customization accordingly.
Method 3: Use a Plugin to Customize The Icon:
If you don’t want to write and use CSS code or work on a child theme, then there is another option to customize your product gallery with the zoom icon. For this, although there are many plugins available, you can use the Custom Product Gallery plugin to customize the icon.
Let’s see some effective steps you need to take if you want to complete this task with the help of a WordPress plugin.
1. Install and Activate the Plugin: Go to your WordPress main dashboard, and from the left-side menu, select ‘Plugins’ and then click on the ‘Add New’ button. In the search bar, type ‘Custom Product Gallery for WooCommerce’ and hit Enter. When the plugin appears, click on the ‘Install’ button and then click on the ‘Activate’ button after a successful installation.
2. Configure Settings: Navigate to the plugin’s settings page and find the option for product zoom features with the magnifying glass icon.
3. Upload Custom Icon: In the plugin settings, you can upload your custom icon and replace the default magnifying glass.
4. Save and Publish: After configuring, make sure you save the settings by clicking on the ‘Publish’ button. After that, don’t forget to check the product pages to see if the changes are accurate.
Pros of This Method:
- You do not need any coding skills.
- You can quickly set up the plugin and make your desired changes.
Cons of This Method:
- You will need to depend on a third-party WordPress plugin.
- Sometimes this plugin may not be compatible with or may conflict with other plugins, creating issues.
Final Thought
Anyone can customize the WooCommerce magnifying glass icon to improve the aesthetics and functionality of their eCommerce store. The three methods above (use custom CSS, use a child theme, or use a third-party plugin) are enough to do it yourself, even if you’re not a developer and don’t have any coding knowledge. Make sure the changes you make enhance the user experience and are responsive. To ensure this, you can test your changes on different devices to see if they work well on all devices and web browsers.
You can also take user feedback to make additional changes if required, and you can seek help from the Stack Overflow community by asking questions about your specific problems.
That’s all for today. Feel free to share this blog on your timeline if you find it helpful.