#php tutorial for absolute beginners
Explore tagged Tumblr posts
Text
How do I become a PHP developer?
Here are the steps on how to become a PHP developer: Learn the basics of PHP. This includes learning the syntax of the language, the different data types, and the basic control structures. You can learn the basics of PHP online or from a book. Build projects. The best way to learn PHP is by building projects. This will help you practice what you have learned and learn new things. You can find…
#php tutorial#php tutorial for beginners#php tutorial for beginners full#php#php programming tutorial#php for beginners#php tutorial for absolute beginners#learn php#php course#php tutorials#php project tutorial#php tutorial 2020#php full course#tutorial#php tutorial login#php programming#php project#php and mysql tutorial for beginners#object oriented php tutorial for beginners#php programming tutorial for beginners#tutorial php#php tutorial 2025
0 notes
Text
Want to learn PHP programming? You can come to the biggest resource page on the Internet for PHP learning. PHP has become one of the most widely used programming languages which can easily be used with different platforms, such as, Linux, Windows, and Unix. Regardless of whether you are working on a big official project or are into internet marketing, PHP is used everywhere. This language is easy to understand and work with, dynamic in nature and can merge with different kinds of RDMS. Experienced PHP programmers may want to also check out the most common libraries in PHP that can make you supercharged PHP developer. If you wish to learn the PHP programming language, you can do so with the help of the following web resources: Best Free Beginners Tutorials On PHP First thing first, these are the best beginners tutorials for learning PHP. PHP 5 Tutorial PHP Tutorial PHP: A simple tutorial - Manual Introduction to PHP | Codecademy PHP Tutorial for Beginners | WIRED PHP 101: PHP For the Absolute Beginner - Zend Developer Zone PHP Tutorials: Beginners PHP Tutorials PHP Tutorial - Introduction PHP Tutorial - Part 1 PHP Tutorials for beginners - w3resource Learn PHP - Free Interactive PHP Tutorial Step-by-Step PHP Tutorials for Beginners - Creating your PHP program FROM SCRATCH: Basic Authentication, Membership and CRUD functionalities - CodeProject Object Oriented PHP for Beginners – KillerPHP.com PHP Tutorial for the Absolute Beginner Best Free Websites About PHP Tutorials One of the best ways to get started with PHP programming language us through an online website which you can access for free. There are free websites for both beginners as well as advanced users and explain all the concepts in great details. The complete PHP 5 tutorial - PHP5 tutorial PHP 5 Tutorial - An Ultimate Guide for Beginners PHP Tutorials : Learn in 7 Days PHP Tutorial | SoloLearn: Learn to code for FREE! PHP Tutorial - javatpoint PHP Tutorial Tutorials | PHP | Google Cloud Platform PHP Tutorials - Tutorialized PHP Tutorial - Table of contentsentutorial - HTML.net PHP Tutorial - PHP programming Reference Free PHP tutorials. Learn PHP, JavaScript, MySQL and how to use phpDesigner 8 MySQL PHP tutorial - MySQL programming with PHP Getting Started with PHP Regular Expressions - noupe Simple Banner Rotator With PHP, jQuery & MySQL | Tutorialzine Build a CMS in an Afternoon with PHP and MySQL PHP and HTML5 Learning Trail - NetBeans IDE Tutorials, Guides and Articles PHP | Tutorials | Webucator PHP Devs Center | Jelastic Dev Docs PHP tutorials, scripts and features from HTMLGoodiesPHP tutorials, scripts and features from HTMLGoodiesPHP tutorials, scripts and features from HTMLGoodiesPHP tutorials, scripts and features from HTMLGoodies PHP Tutorial – Learn PHP for beginners and advanced level | Tutorials Collection php pdf tutorial Convert HTML To PDF in PHP The Easy Way PHP MySQL Tutorial List files and directories in PHP Best Free PHP Video Tutorials The free video tutorials are the best way to get abreast with the language if you are more of a visual learner. You will get to learn from PHP experts and professionals, who will take you through a visual presentation and working of the language. PHP Programming Tutorials For Beginners - YouTube PHP Tutorials - Free Computer-Science Video Lectures PHP Tutorials Playlist - YouTube PHP - YouTube OOP PHP - YouTube PHP Tutorial - YouTube PHP Video Tutorial - YouTube PHP Security - YouTube PHP Tutorial for Beginners (For Absolute Beginners) - YouTube PHP Tutorials - YouTube PHP Tutorials - YouTube PHP Complete Series - YouTube PHP GD Image Processing Video Textbook Programming Tutorials - YouTube Ecommerce Website Tutorial PHP MySQL Tutorial PayPal IPN - YouTube How to Build Custom CMS Website Software Using PHP and MySQL - YouTube PHP Beginner Complete Tutorials - YouTube Bucky's Beginner PHP Programming Tutorial Series - YouTube
PHP MYSQL tutorials In Hindi for beginners (Core PHP) - YouTube PHP Tutorial for Beginners - 01 - Introduction - YouTube PHP Tutorial in Filipino - YouTube PHP Fundamentals Tutorial (Bangla) - YouTube Tutorial PHP MySQL Web Development - YouTube Curso de PHP - YouTube PHP & MySQL tutorials in Urdu/Hindi - YouTube PHP Tutorial In Tamil - YouTube Advanced OOP PHP tutorial - YouTube Core PHP complete/full tutorial series for beginners - YouTube PHP OOP Tutorials - YouTube WebDevlopment|PHP by Manideep - YouTube Best Free PHP ebooks and PDF Tutorials There are many free ebooks which will help you learn the language in the most appropriate manner and can be easily downloaded from the internet. Some of the books require you to have some programming background but most of them explain everything from scratch. PHP Tutorial PDF - Phptpoint.com ePub ebook PHP Reference: Beginner to Intermediate PHP5 PHP-Tutorial(w3schools).pdf Php Http Cookie PDF format tutorial for PHP MySQL PHP Api documentation PHP Tutorial From beginner to master Learn Object Oriented Programming (OOP) in PHP Programming PHP by Oreilly PHP Beginners Guide PHP Reference: Beginner to Intermediate PHP PHP Introduction to Server-Side Programming Creating dynamic Web sites with PHP and MySQL : IBM PHP 5 Power Programming PHP Manual CakePHP Cookbook Documentation Linux, Apache, MySQL, Perl/PHP/Python (LAMP) How To Build a LAMP Server Best PHP Blogs From Expert PHP Programmers and More PHP has a vibrant community of highly skilled programmers. This is the reason you will find many excellent blogs on PHP and related technology. PHP: Hypertext Preprocessor Tutorials | PHP | HTML | CSS | JavaScript | PHPJabbers PHP Tutorials for Beginners and Programmers | Codementor nikic's Blog blog.phpdev David Walsh Blog - JavaScript Consultant Roshan Bhattarai's Blog - A blog about PHP, Ajax, JavaScript, CSS, Web 2.0 and Web Development Chris Shiflett Paul M. Jones | There are no solutions, only tradeoffs. PHP – There and Back Again Stuart on PHP - Web Development Blog Programming, Books, Tutorials | FromDev: Search results for php PHP Tutorials Blog on Sitepoint Schlitt Blog About Tutorials on PHP Best Free PHP Forums and Massage Boards to Ask Questions The PHP web forums allow you to gain easy access to free and open source communities. These will help you become a part of the online virtual community wherein you can interact, share items and discuss. phpBB - Free and Open Source Forum Software Newest 'php' Questions - Stack Overflow PHPBuilder.com PHP Freaks PHP forum, your PHP coding community - Index page PHP PHP- Webdeveloper.com PHP - The SitePoint Forums Best Free Cheat Sheets for PHP Quick Reference These PHP cheat sheets enable you to take a quick look at the various important concepts of the language, without undertaking any in-depth study. PHP is used in almost all the popular platforms like Facebook, WordPress, Wikipedia, Joomla and Drupal. So, even if you are not looking forward to develop a similar platform, you will still require to learn the language if you wish to customize or integrate with any of the applications. BlueShoes: PHP Cheat Sheet PHP 5.4 - Dzone Refcardz PHP Refcard Available - Download Now - DZone PHP Cheat Sheet | OverAPI.com PHP Cheatsheets PHP Cheat Sheet by DaveChild PHP Cheatsheet By Expression Engine PHP Cheatsheet by Digilife PHP Cheatsheet by DreaminCode PHP Ref Card PHP Cheatsheet
0 notes
Text
Can I Be a Full-Stack Developer with Python?
The field of software development is vast, and one question that often arises among aspiring developers is whether they can become full-stack developers using Python. This inquiry is particularly relevant given the increasing popularity of Python as a programming language due to its simplicity, versatility, and extensive library support. In this article, we'll explore what it means to be a full-stack developer, how Python fits into the equation, and the steps you can take to become a proficient full-stack developer using Python.
Understanding Full-Stack Development
Full-stack development refers to the ability to work on both the front-end and back-end of a web application. A full-stack developer is someone who possesses a comprehensive understanding of the various layers involved in web development, allowing them to create complete, functional web applications.
Key Components of Full-Stack Development
Front-End Development: This involves everything that users interact with directly in their web browsers. Front-end technologies typically include:
HTML: The standard markup language for creating web pages.
CSS: Used for styling HTML elements and making web pages visually appealing.
JavaScript: A programming language that enables interactive elements on web pages.
Back-End Development: This encompasses the server side of an application where data is processed, stored, and managed. Key components include:
Server-Side Languages: Languages like Python, Ruby, Java, and PHP are used to create server-side logic.
Databases: Systems like MySQL, PostgreSQL, and MongoDB are used to store and manage application data.
Server Management: Understanding how servers operate and how to deploy applications.
APIs: Application Programming Interfaces (APIs) allow different software applications to communicate. Full-stack developers often build and consume APIs to enable front-end and back-end integration.
Can You Be a Full-Stack Developer with Python?
Yes, you can absolutely become a full-stack developer using Python! In fact, Python is an excellent choice for full-stack development due to its versatility and the wealth of frameworks and libraries available for both front-end and back-end development.
Advantages of Using Python for Full-Stack Development
Ease of Learning: Python’s syntax is straightforward and readable, making it an ideal language for beginners. This can accelerate your learning curve as you delve into both front-end and back-end technologies.
Rich Ecosystem: Python boasts a rich ecosystem of frameworks and libraries that can facilitate rapid development. Some popular choices include:
Django: A high-level web framework that encourages rapid development and clean, pragmatic design. Django comes with built-in features like an ORM (Object-Relational Mapping), user authentication, and admin panel, making it easier to build robust back-end applications.
Flask: A micro-framework for Python that is lightweight and flexible, allowing developers to build web applications quickly and with more control over the components used.
Full-Stack Frameworks: Full-stack frameworks like Django can handle both front-end and back-end development. Django's templating engine allows for easy integration of front-end technologies, while its robust back-end capabilities manage data and business logic.
Community Support: Python has a large, active community, which means you’ll find plenty of resources, tutorials, and forums to assist you in your journey to becoming a full-stack developer.
How to Become a Full-Stack Developer with Python
If you’re looking to become a full-stack developer using Python, here’s a step-by-step approach:
Learn the Basics of Python:
Start with the fundamentals of Python programming. Familiarize yourself with data types, control structures, functions, and object-oriented programming.
Explore Front-End Technologies:
HTML: Learn how to structure web pages using HTML.
CSS: Understand styling and layout techniques to make your web applications visually appealing.
JavaScript: Get comfortable with JavaScript for creating interactive web elements. Frameworks like React, Vue.js, or Angular can also enhance your front-end development skills.
Master a Python Web Framework:
Choose a Python web framework like Django or Flask and learn how to build web applications with it. Focus on understanding how to create routes, handle requests, and manage databases.
Understand Databases:
Learn about databases and how to interact with them. Understand SQL (for relational databases) and NoSQL databases (like MongoDB). Explore ORMs, especially if you're using Django.
Learn About APIs:
Understand how to create and consume APIs. Practice building RESTful services using Django REST framework or Flask.
Deploy Your Applications:
Familiarize yourself with deployment practices. Learn how to use cloud services like Heroku, AWS, or DigitalOcean to host your applications.
Build Projects:
The best way to learn is by doing. Create projects that showcase your skills in both front-end and back-end development. Consider contributing to open-source projects or collaborating with others.
Stay Updated:
The tech field is ever-evolving. Keep learning new technologies and frameworks to stay relevant in the industry. Follow industry news, participate in coding communities, and engage with fellow developers.
Conclusion
In conclusion, becoming a full-stack developer with Python is not only possible but also highly rewarding. With Python’s versatility and the wealth of frameworks available, you can efficiently build both front-end and back-end components of web applications. By following a structured learning path, engaging in practical projects, and continuously improving your skills, you can carve a successful career in full-stack development.
Embrace the journey, stay curious, and enjoy the process of creating dynamic web applications with Python!
0 notes
Text
Monster Legends Free Gems Tips
Go here🔥🔥: Monster Legends Free Gems Cheat
Guide to MONSTER LEGENDS precious metal and gems totally free Here we describe how to make use of it, without the infidelity, without human confirmation, without scams, plus best of almost all , without having in order to pay! You will certainly only have in order to follow these actions: You must pick the amount of precious metal gems that a person want to acquire , and press "generate". Monster Legends fourteen. 2023 ( MOD- Unlimited Gems)- Apk Beast Legends Unlimited Cash Generating Money upon the game is absolutely do with the Beast Legends Mod Apk. Monster Legends Tricks- Cheats. will be Download Free Install Monster Tales Cheats Cheats plus the Cheat Motor Double- click on the . CT document to spread away it. FREE BEAST LEGENDS GOLD GEMSTONES GENERATOR 2023. Simply no Human Free Beast Legends Gold Gemstones Generator. Monster Tales Tricks- How in order to get Monster Tales Gems Gold. Examine boxes to trigger trainer options or even set values through 0- one Also, check Lifeless Rising Cheats Simply Cause 4 Tricks Xbox One Beast Legends 14. a few . 1( MOD-- Unlimited Gems) Down load on android-- Apkdlay Open Downloading on your gadget by going in order to My Files Faucet the APK document you downloaded( es. socialpoint. MonsterLegends) Simply download button beneath Cons: Downloading Beast Legends from-- party sources are usually not usually examined by Google. This can start the set up process. Monster Tales Online Generator-- Free Gems plus Gold Welcome in order to the Monster Tales Cheats or even Monster Legends Cheats device site. After filling up in the areas . Monster Legends Cheats- Getting TOTALLY FREE Gems Gold( NO SURVEY). Once we pointed out in our tricks and tips for beginners , each new account ought to prioritize gold obtain to start out with. Beast Legends Free Gems plus Gold Cheat. beast legends mod apk 2023. Gems are usually mainly utilized to velocity up upgrades, activities, and purchasing creatures, cells, gold, plus food. Monster Tales Online Generator. Quick Algorithm The primary from the database will be coded in PHP and best feasible way so crack process is going to be speediest possible. The easiest method to Obtain FREE Gold within Monster Legends. Acquiring Free Gems Gamers can earn gemstones little by little through game play by: Generator BEAST LEGENDS gold plus gems free. Even though they did function, by using a cheat or even would probably bring about your becoming banned. You need to gather. The next stage to follow along with is in order to decide and pick the number of totally free gold gems you would like to generate. Mod Functions No Ads. Beast Legends Operating 100 and Evidence No Survey Immediate Download experience multiplier– ca nt wait around to unlock things because your degree is simply too low? make use of this option plus make sure beast legends cheat device is running whilst your are actively playing the overall game battle stage. The database regarding Monster Legends that will anyone can modify ! Please read our own Wiki Rules prior to contributing. Monster Tales APK+ IMOD( Always Win a few Stars) v13. one. 1 MOD APK version of Beast Legends. monster tales unlimited every thing . Monster Legends imod is really a private machine mod. the way to get totally free gems monster tales. You can obtain Monster Legends crack gems 99999 simply by clicking the switch below: Click Right here To Get Beast Legends Free Gemstones! Now that a person are in , place your game user name in order that server may locate your accounts.
Monster Legends-- Getting Gold Ra 100%( No Hack). How To Obtain GEMS in Beast Legends for Totally free 2022( iOS/ Android) SIMPLE Monster Legends Jewel Glitch! Monster Tales: How To Obtain FREE Rewards!| FREE Gems& More! Monster Tales: Ways to get GEMS| How you can Farm GEMSTONES In 2021! Exactly how to Get Totally free Gems in Beast Legends EASILY 2022 GEMS TUTORIAL Crack Update Android/ iOS Beast Legends GEM CRACK?!| HOW A LOT I PAID WITH REGARD TO 13 MILLION GEMSTONES. Monster Legends Imod Apk v14. one. 5 Unlimited Every thing Download The imod apk of Beast Legends Mod Apk gives players limitless gold. Monster Tales- Steps to make A lot more Gold- Precious metal Farming Guide Beast Legends on PERSONAL COMPUTER – Gold Gardening Guide| BlueStacks Although gold will be not the high quality currency of Beast Legends, it will be the most utilized in - sport coinage. The Beast Legends Wiki offersenergetic Users since through March 15, this year ! Note: This will be an English Wiki, please usually do not include content to this particular Wiki in some other languages. Collecting precious metal from the monsters 'habitats is the key method to acquire gold, but this can be earned within other ways , such as selling items, creatures and/or monster ovum, and winning this as a incentive. Monster Legends-- Gold Ra]Coaching Skill& Combat]. Monster Legends Crack 2022- Obtain Cheats For Totally free Gems. A summary associated with the Monster Tales Game. The goal of the overall game will be to lead the team of creatures through levels, saving captives and gathering gold coins whilst avoiding obstacles plus enemies.
8 notes
·
View notes
Photo

Learn PHP Programming - PHP Tutorial for for Absolute Beginner ☞ https://morioh.com/p/bdc864e23bd2 #PHP #Morioh
6 notes
·
View notes
Text
WHY SHOULD EVERY STARTUP THINK ABOUT WEB DEVELOPMENT?
Website development is basically the task of creating a website for either the World Wide Web or an internal network (intranet). Development usually involves creating a simple single page of plain text or perhaps with a few lines of code. The next level-up would be building an interactive website, one with interactive elements such as drop-down menus, forms, search boxes, pop-up boxes, and images. Then you get to the really complicated stuff, which involves things like Java, Flash, and other kinds of multimedia systems, as well as database and content management systems.
Every Beginning Shouldn’t be Hard with Professional Website
The importance of websites for startups and small businesses in the world today is undeniable. Online shopping has become extremely popular over the last decade, and this popularity continues to grow. According to numerous web development agencies in Dubai, millions of people turn to the internet to do their shopping, and millions more use alternative shopping websites for the convenience of having everything they need to be shipped directly to their door. Because of these changes in customer expectations, website designers must work closely with marketing professionals to ensure that the final product is both user-friendly, attractive, and appropriate for the target market. This is why website development and marketing are absolutely integral parts of every business’ web strategy.
In fact, many small businesses mistakenly believe that their budgets should only cover the coding and design aspects of their websites. While the coding and design work is essential, be prepared to spend some money on web designers. While not nearly as important as the coding, marketing and advertising elements will make or break your business.
These are some of the things every startup should consider when it comes to web development:
1. It’s Hard to Develop, But It’s Worth Your Time and Money
One of the first things you must understand about website design and programming is that the internet is not a simple system. It’s filled with millions upon millions of programs and scripts, many of which will interact with each other. For instance, when building web pages, you may be writing HTML code, but the program that produces that HTML code is also writing JavaScript code, which interacts with your photos and videos. So, you must hire a professional web development agency in Dubai that’ll provide you with HTML experts. Moreover, these experts should understand the intricacies of all the various programs and scripts that make up your website. Otherwise, you’ll experience a lot of trouble when starting up your website, and it won’t be easy to make it run smoothly.
2. Web Development with Easy-to-Use Platforms
Even though hundreds of different website development platforms are available today, two of the most popular remain WordPress and Joomla. Every web development company in Dubai will tell you that both platforms are prevalent because they’re easy to use and have built-in SEO functionality. As a result, even someone relatively new to website development can build a great website, and it’ll start earning money almost immediately. WordPress, however, has become extremely popular among small businesses because of its flexible licensing terms. While Joomla does have rigid licensing terms, it’s still much more flexible to use than WordPress, and that’s why lots of startups are switching to Joomla over WordPress to develop their websites.
3. You Can Choose a Web Development Platform According to Your iOS
There are several key differences between WordPress and Joomla. Firstly, WordPress uses a version of PHP that’s called PHP/Linux-PHP. While this sounds like almost every website developer’s favorite, it’s actually not. Joomla is written in C++ and therefore works well on both Windows and Linux computers. Thus, if you’re a Windows user, then you can definitely use Joomla.
Secondly, both Joomla and WordPress allow their users to create a “front-end” or user interface, which the end-user sees when visiting a website. In other words, these applications allow the person reading your website to interact with it. If you’re writing code, then you probably know how challenging this can be. You want to be able to interact with the data, the layout, the colors, and so forth from a client, not having to go back to add in the code. If at any point you decide you need professional help, locate the closest web development agency in Dubai and hire them to develop you an incredible website.
4. Having Stable Coding Languages is of Vital Importance
Both WordPress and Joomla are written in very stable languages. Both languages are multithreaded, meaning that multiple threads can execute code simultaneously without any crashing or error messages being displayed. This means that both programmers and developers can simultaneously work on the project without any worries whatsoever. Programmers especially prefer these languages as they’ll never have to worry about them crashing. This, along with the fact that both languages are used worldwide, makes them some of the most sought-after coding languages today.
5. Ease-of-Use Allows Beginners to Develop Incredible Websites
Both Joomla and WordPress platforms are very intuitive, and there are plenty of materials and tutorials available online, so even beginners can develop their first websites. Sometimes hiring a web development company in Dubai may seem completely unnecessary, but truth to be told, it’s always better to leave web development to professionals. Having a professional backup is of vital importance if anything goes wrong with your web development project. For inexperienced people, web development may seem overwhelming. That’s why hiring some of the best web development companies in Dubai is a great idea as they offer various services to startups and small businesses. We at Igloo marketing agency can help you develop a website from your dreams without any hassle whatsoever, so make sure to contact us whenever you need our help.
Wrapping Up
Even though it’s quite straightforward to build your own website from scratch, there’s plenty of things you’d have to learn to complete this project successfully. Besides, building a website isn’t the only thing a startup needs, as marketing is vital for success as well. So, if you don’t want to waste months of your time and energy, make sure to hire professional help and let us do the work for you.
https://www.weareigloo.com/why-should-every-start-up-think-about-web-development/
1 note
·
View note
Photo

PHP Tutorial for Absolute Beginners - PHP Full Course 2020 ☞ https://bit.ly/2XF3E7Y #PHP #Morioh
2 notes
·
View notes
Photo

Laravel 6 PHP Framework Tutorial - Full Course for Absolute Beginners ☞ http://bit.ly/2MiHT7X #Laravel #PHP #Morioh
#Laravel#Laravel Tutorial#Laravel 5.8#Laravel 5.8 Tutorial#Laravel 6#Laravel 6 tutorial#learn to code#learn code#Codequs#Morioh
1 note
·
View note
Photo

Laravel 6 PHP Framework Tutorial - Full Course for Absolute Beginners ☞ https://codequs.com/p/BJUbxbVtB/laravel-6-php-framework-tutorial-full-course-for-absolute-beginners #php #laravel
4 notes
·
View notes
Photo

Learn PHP Programming - PHP Tutorial for for Absolute Beginner ☞ https://morioh.com/p/bdc864e23bd2 #PHP #Morioh
2 notes
·
View notes
Photo

Laravel 6 PHP Framework Tutorial - Full Course for Absolute Beginners ☞ https://codequs.com/p/BJUbxbVtB/laravel-6-php-framework-tutorial-full-course-for-absolute-beginners #php #programming
1 note
·
View note
Photo

Laravel 6 PHP Framework Tutorial - Full Course for Absolute Beginners ☞ http://bit.ly/37VCPPK #php #laravel
1 note
·
View note
Photo

Learn PHP Programming - PHP Tutorial for for Absolute Beginner ☞ https://morioh.com/p/bdc864e23bd2 #PHP #Morioh
1 note
·
View note
Photo

Learn PHP Programming - PHP Tutorial for for Absolute Beginner ☞ https://morioh.com/p/bdc864e23bd2 #PHP #Morioh
4 notes
·
View notes
Photo
How to Create Your Own AJAX WooCommerce Wishlist Plugin
In this tutorial we will create lightweight wishlist functionality for WooCommerce using AJAX, WordPress REST API, and SVG graphics. WooCommerce doesn’t come with wishlist functionality as standard, so you’ll always need to rely on an extension to do the work for you. Unless you build it yourself for complete control..
Wish Upon a Star
Wishlist functionality will allow users to mark certain products, adding them to a list for future reference. In some eCommerce stores (such as Amazon) multiple wishlists can be created, and these can be shared with others, which makes them ideal for birthdays or weddings. In our case, the WooCommerce wishlist we’re going to create will enable customers to easily revisit products they’re considering.
Our wishlist functionality will add a heart icon to the product thumbs, which when clicked will add the product to a wishlist in a table.
Click the heart icon to add a product to the wishlist
Take a look at the demo for a proper idea of how it works.
1. Create the Plugin Structure
Let’s start by building our plugin. Create a folder with the name “wishlist” and a PHP file with the same name. Add the following snippet to the PHP file:
/* Plugin Name: Woocommerce wishlist Plugin URI: https://www.enovathemes.com Description: Ajax wishlist for WooCommerce Author: Enovathemes Version: 1.0 Author URI: http://enovathemes.com */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly }
We won’t go into detail about the plugin creation process, but if you are new to plugin development I highly recommend this amazing new course by Rachel McCollin:
WordPress
Introduction to WordPress Plugin Development
Rachel McCollin
Add the Plugin Functions
Let’s sketch out our plan so we know what to build:
Add wishlist toggle to products in loop and single pages using WooCommerce hooks
Create wishlist table shortcode to hold the products added to the wishlist
Create wishlist custom option in the user profile
All the plugin code will go inside the init action for the plugin, as we first need to make sure that the WooCommerce plugin is active. So right after the plugin details add the following code:
add_action('init','plugin_init'); function plugin_init(){ if (class_exists("Woocommerce")) { // Code here } }
And now let’s enqueue our plugin scripts and styles.
Add the following code to the main plugin file:
function wishlist_plugin_scripts_styles(){ wp_enqueue_style( 'wishlist-style', plugins_url('/css/style.css', __FILE__ ), array(), '1.0.0' ); wp_enqueue_script( 'wishlist-main', plugins_url('/js/main.js', __FILE__ ), array('jquery'), '', true); wp_localize_script( 'main', 'opt', array( 'ajaxUrl' => admin_url('admin-ajax.php'), 'ajaxPost' => admin_url('admin-post.php'), 'restUrl' => rest_url('wp/v2/product'), 'shopName' => sanitize_title_with_dashes(sanitize_title_with_dashes(get_bloginfo('name'))), 'inWishlist' => esc_html__("Already in wishlist","text-domain"), 'removeWishlist' => esc_html__("Remove from wishlist","text-domain"), 'buttonText' => esc_html__("Details","text-domain"), 'error' => esc_html__("Something went wrong, could not add to wishlist","text-domain"), 'noWishlist' => esc_html__("No wishlist found","text-domain"), ) ); } add_action( 'wp_enqueue_scripts', 'wishlist_plugin_scripts_styles' );
Here we enqueue the main style.css file and the main.js file for the plugin, also we pass some parameters to the main.js file to work with:
ajaxUrl – required to fetch some data from WordPress, like current User ID
ajaxPost – required to update user wishlist
restUrl – required to list the wishlist items in the wishlist table
shopName – required to add wishlist items to the session storage for non-registered or non-logged-in users
And some strings instead of hardcoding them into the js file, in case they need to be translatable.
So for now create a css, and js folder and put the corresponding files inside those folders: style.css in the css folder and main.js in the js folder.
2. Hook the Wishlist Toggle
Right inside the init action add the following code:
// Add wishlist to product add_action('woocommerce_before_shop_loop_item_title','wishlist_toggle',15); add_action('woocommerce_single_product_summary','wishlist_toggle',25); function wishlist_toggle(){ global $product; echo '<span class="wishlist-title">'.esc_attr__("Add to wishlist","text-domain").'</span><a class="wishlist-toggle" data-product="'.esc_attr($product->get_id()).'" href="#" title="'.esc_attr__("Add to wishlist","text-domain").'">'.file_get_contents(plugins_url( 'images/icon.svg', __FILE__ )).'</a>'; }
Here we add a wishlist toggle to each product in the loop and to each single product layout, using the woocommerce_before_shop_loop_item_title and woocommerce_single_product_summary hooks.
Here I want to point out the data-product attribute that contains the product ID–this is required to power the wishlist functionality. And also take a closer look at the SVG icon–this is required to power the animation.
3. Add SVG Icons
Now create an images folder in the plugin folder and put the following icon.svg in it:
<svg viewBox="0 0 471.701 471.701"> <path class="heart" d="M433.601,67.001c-24.7-24.7-57.4-38.2-92.3-38.2s-67.7,13.6-92.4,38.3l-12.9,12.9l-13.1-13.1 c-24.7-24.7-57.6-38.4-92.5-38.4c-34.8,0-67.6,13.6-92.2,38.2c-24.7,24.7-38.3,57.5-38.2,92.4c0,34.9,13.7,67.6,38.4,92.3 l187.8,187.8c2.6,2.6,6.1,4,9.5,4c3.4,0,6.9-1.3,9.5-3.9l188.2-187.5c24.7-24.7,38.3-57.5,38.3-92.4 C471.801,124.501,458.301,91.701,433.601,67.001z M414.401,232.701l-178.7,178l-178.3-178.3c-19.6-19.6-30.4-45.6-30.4-73.3 s10.7-53.7,30.3-73.2c19.5-19.5,45.5-30.3,73.1-30.3c27.7,0,53.8,10.8,73.4,30.4l22.6,22.6c5.3,5.3,13.8,5.3,19.1,0l22.4-22.4 c19.6-19.6,45.7-30.4,73.3-30.4c27.6,0,53.6,10.8,73.2,30.3c19.6,19.6,30.3,45.6,30.3,73.3 C444.801,187.101,434.001,213.101,414.401,232.701z"/> <g class="loading"> <path d="M409.6,0c-9.426,0-17.067,7.641-17.067,17.067v62.344C304.667-5.656,164.478-3.386,79.411,84.479 c-40.09,41.409-62.455,96.818-62.344,154.454c0,9.426,7.641,17.067,17.067,17.067S51.2,248.359,51.2,238.933 c0.021-103.682,84.088-187.717,187.771-187.696c52.657,0.01,102.888,22.135,138.442,60.976l-75.605,25.207 c-8.954,2.979-13.799,12.652-10.82,21.606s12.652,13.799,21.606,10.82l102.4-34.133c6.99-2.328,11.697-8.88,11.674-16.247v-102.4 C426.667,7.641,419.026,0,409.6,0z"/> <path d="M443.733,221.867c-9.426,0-17.067,7.641-17.067,17.067c-0.021,103.682-84.088,187.717-187.771,187.696 c-52.657-0.01-102.888-22.135-138.442-60.976l75.605-25.207c8.954-2.979,13.799-12.652,10.82-21.606 c-2.979-8.954-12.652-13.799-21.606-10.82l-102.4,34.133c-6.99,2.328-11.697,8.88-11.674,16.247v102.4 c0,9.426,7.641,17.067,17.067,17.067s17.067-7.641,17.067-17.067v-62.345c87.866,85.067,228.056,82.798,313.122-5.068 c40.09-41.409,62.455-96.818,62.344-154.454C460.8,229.508,453.159,221.867,443.733,221.867z"/> </g> <g class="check"> <path d="M238.933,0C106.974,0,0,106.974,0,238.933s106.974,238.933,238.933,238.933s238.933-106.974,238.933-238.933 C477.726,107.033,370.834,0.141,238.933,0z M238.933,443.733c-113.108,0-204.8-91.692-204.8-204.8s91.692-204.8,204.8-204.8 s204.8,91.692,204.8,204.8C443.611,351.991,351.991,443.611,238.933,443.733z"/> <path d="M370.046,141.534c-6.614-6.388-17.099-6.388-23.712,0v0L187.733,300.134l-56.201-56.201 c-6.548-6.78-17.353-6.967-24.132-0.419c-6.78,6.548-6.967,17.353-0.419,24.132c0.137,0.142,0.277,0.282,0.419,0.419 l68.267,68.267c6.664,6.663,17.468,6.663,24.132,0l170.667-170.667C377.014,158.886,376.826,148.082,370.046,141.534z"/> </g> </svg>
If you are new to working with SVGs I highly recommend you read these amazing tutorials on the subject:
SVG
How to Hand Code SVG
Kezz Bracey
SVG
SVG Viewport and viewBox (For Complete Beginners)
Kezz Bracey
Our SVG animation has 3 states:
Default: the heart path
Process: loading group (g tag)
End: check group (g tag)
If you now go to your shop page you will see the unstyled SVG icons piled on top of each other:
Let’s add some styling to fix this mess! Open the style.css file and paste the following code:
.wishlist-toggle { display: block; position: absolute; top: 16px; left: 16px; z-index: 5; width: 24px; height: 24px; outline: none; border:none; } .wishlist-title { display: none; } .entry-summary .wishlist-toggle { position: relative; top: 0; left: 0; display: inline-block; vertical-align: middle; margin-bottom: 8px; } .entry-summary .wishlist-title { display: inline-block; vertical-align: middle; margin-right: 8px; margin-bottom: 8px; } .wishlist-toggle:focus { outline: none; border:none; } .wishlist-toggle svg { fill:#bdbdbd; transition: all 200ms ease-out; } .wishlist-toggle:hover svg, .wishlist-toggle.active svg { fill:#000000; } .wishlist-toggle svg .loading, .wishlist-toggle svg .check { opacity: 0; } .wishlist-toggle.active svg .check { opacity: 1; } .wishlist-toggle.active svg .heart { opacity: 0; } .wishlist-toggle.loading svg .loading, .wishlist-table.loading:before { animation:loading 500ms 0ms infinite normal linear; transform-origin: center; opacity: 1; } .wishlist-toggle.loading svg .heart { opacity:0; } @keyframes loading { from {transform: rotate(0deg);} to {transform: rotate(360deg);} }
The logic here is as follows:
Initially we show the heart path of our SVG.
When the user clicks on it we will hide the heart path and show the loading path.
Once the loading finishes we will show the checkmark indicating that the product was successfully added to the wishlist.
We will toggle the loading state via JavaScript later; the loading animation is a simple transform rotate. So for now if you refresh the page (don’t forget to clear the browser cache as sometimes old styles are cached) you will see a nice heart icon with each product.
This toggle currently does nothing, so we’ll sort that out. But for now let’s keep with our plan.
4. Create Wishlist Table Shortcode
Add the following code in the init plugin action:
// Wishlist table shortcode add_shortcode('wishlist', 'wishlist'); function wishlist( $atts, $content = null ) { extract(shortcode_atts(array(), $atts)); return '<table class="wishlist-table loading"> <tr> <th><!-- Left for image --></th> <th>'.esc_html__("Name","text-domain").'</th> <th>'.esc_html__("Price","text-domain").'</th> <th>'.esc_html__("Stock","text-domain").'</th> <th><!-- Left for button --></th> </tr> </table>'; }
This is a very simple shortcode that you can add to any page, and the wishlist items will appear inside it. I won’t describe the shortcode creation process, but if you are new to this, I highly recommend reading this amazing tutorial:
Plugins
Getting Started With WordPress Shortcodes
Rohan Mehta
Make a Wishlist Page
Now from inside the WP admin create a page called “Wishlist” and put the [wishlist] shortcode inside it. Now if you go to the wishlist page you will see an empty table.
Did you notice the loading class on the table? We will remove the loading class with JavaScript later, once the wishlist items are ready to be appended to the table. But for now open the style.css and add the following code:
.wishlist-table { width:100%; position: relative; } .wishlist-table.loading:after { display: block; width: 100%; height: 100%; position: absolute; top: 0; left: 0; content: ""; background: #ffffff; opacity: 0.5; z-index: 5; } .wishlist-table.loading:before { display: block; width: 24px; height: 24px; position: absolute; top: 50%; left: 50%; margin-top:-12px; margin-left:-12px; content: ""; background-image: url('../images/loading.svg'); background-repeat: no-repeat; background-size: 100%; z-index: 6; } .wishlist-table td { position: relative; } .wishlist-table a.details { padding:4px 16px; background: #000000; color: #ffffff; text-align: center; border:none !important } .wishlist-table a.wishlist-remove { display: block; width: 24px; height: 24px; position: absolute; top: 50%; left: 50%; margin-top:-12px; margin-left:-12px; background-image: url('../images/remove.svg'); background-repeat: no-repeat; background-size: 100%; z-index: 6; border:none; opacity:0; } .wishlist-table td:hover > a.wishlist-remove { opacity:1; }
Add the loading.svg image to the images folder:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 471.701 471.701"> <path d="M409.6,0c-9.426,0-17.067,7.641-17.067,17.067v62.344C304.667-5.656,164.478-3.386,79.411,84.479 c-40.09,41.409-62.455,96.818-62.344,154.454c0,9.426,7.641,17.067,17.067,17.067S51.2,248.359,51.2,238.933 c0.021-103.682,84.088-187.717,187.771-187.696c52.657,0.01,102.888,22.135,138.442,60.976l-75.605,25.207 c-8.954,2.979-13.799,12.652-10.82,21.606s12.652,13.799,21.606,10.82l102.4-34.133c6.99-2.328,11.697-8.88,11.674-16.247v-102.4 C426.667,7.641,419.026,0,409.6,0z"/> <path d="M443.733,221.867c-9.426,0-17.067,7.641-17.067,17.067c-0.021,103.682-84.088,187.717-187.771,187.696 c-52.657-0.01-102.888-22.135-138.442-60.976l75.605-25.207c8.954-2.979,13.799-12.652,10.82-21.606 c-2.979-8.954-12.652-13.799-21.606-10.82l-102.4,34.133c-6.99,2.328-11.697,8.88-11.674,16.247v102.4 c0,9.426,7.641,17.067,17.067,17.067s17.067-7.641,17.067-17.067v-62.345c87.866,85.067,228.056,82.798,313.122-5.068 c40.09-41.409,62.455-96.818,62.344-154.454C460.8,229.508,453.159,221.867,443.733,221.867z"/> </svg>
This is the same loading SVG separated from the main icon.svg. We could use SVG sprites, but I decided to stick with a separate loading SVG.
Now, if you go to the wishlist page and refresh it you will see an empty table with loading on it. Nice, let’s move further.
5. Wishlist Custom Option in the User Profile
Our wishlist functionality will work both for logged-in users and guest users. With logged-in users we’ll store the wishlist information in the user’s metadata, and with guest users we’ll store the wishlist in the session storage.
You can also store the guest users’ wishlist in local storage, the difference being that session storage is destroyed when the user closes the tab or browser, and local storage is destroyed when the browser cache is cleared. It is up to you which option you use for guest users.
Now add the following code to the init action:
// Wishlist option in the user profile add_action( 'show_user_profile', 'wishlist_user_profile_field' ); add_action( 'edit_user_profile', 'wishlist_user_profile_field' ); function wishlist_user_profile_field( $user ) { ?> <table class="form-table wishlist-data"> <tr> <th><?php echo esc_attr__("Wishlist","text-domain"); ?></th> <td> <input type="text" name="wishlist" id="wishlist" value="<?php echo esc_attr( get_the_author_meta( 'wishlist', $user->ID ) ); ?>" class="regular-text" /> </td> </tr> </table> <?php } add_action( 'personal_options_update', 'save_wishlist_user_profile_field' ); add_action( 'edit_user_profile_update', 'save_wishlist_user_profile_field' ); function save_wishlist_user_profile_field( $user_id ) { if ( !current_user_can( 'edit_user', $user_id ) ) { return false; } update_user_meta( $user_id, 'wishlist', $_POST['wishlist'] ); }
Again, in order to remain within the scope of this tutorial, I won’t explain how to work with user metadata. If you are new to this I highly recommend reading this amazing tutorial:
WordPress
How to Work With WordPress User Metadata
Tom McFarlin
All we do here is create a text field input that will hold the wishlist items comma-separated IDs. With show_user_profile and edit_user_profile actions we add the structure of the input field, and with personal_options_update and edit_user_profile_update actions we power the save functionality.
So once the wishlist is updated it will save to the database. I you go to your profile page you will see a new text field added to it. Add whatever value you want and hit save to test if the update functionality works. With admin CSS you can hide this field if you don’t want users to see it. I will leave it as is.
6. Turn it On!
Now we are ready to power everything up!
Open the main.js file and put the following code in it:
(function($){ "use strict"; })(jQuery);
All our code will go inside this function.
Now let’s gather the required data and create some variables:
var shopName = opt.shopName+'-wishlist', inWishlist = opt.inWishlist, restUrl = opt.restUrl, wishlist = new Array, ls = sessionStorage.getItem(shopName), loggedIn = ($('body').hasClass('logged-in')) ? true : false, userData = '';
As you might remember when we enqueued our main.js script we passed some parameters to it. Here, with JavaScript, we can collect these parameters.
Next, we will create an empty wishlist array that will contains wishlist items. We will need the session storage data with our shop name (the ls variable stands for local storage), and we will need to know if the user is guest or logged-in.
Let me explain the logic here: whenever the user visits the shop page we will need to know if he or she is logged-in or is a guest-user. If the user is logged-in we will need to check if he or she has wishlist items, and if so highlight these items. If not we need to see if there are any items in the session/local storage and highlight those.
Why this is done like this? Imagine, if the user first visits the website as a guest, adds items to the wishlist, and then decides to login. If the user does not have items registered in the profile wishlist, we will need to show the ones that he or she added before login, that are stored in the session/local storage.
So let’s do that step by step:
If User is Logged-in
Fetch current user data with AJAX
If success update the wishlist
Highlight the wishlist items
Remove the session/local storage
If fail show error message in the console for the developer
if(loggedIn) { // Fetch current user data $.ajax({ type: 'POST', url: opt.ajaxUrl, data: { 'action' : 'fetch_user_data', 'dataType': 'json' }, success:function(data) { userData = JSON.parse(data); if (typeof(userData['wishlist']) != 'undefined' && userData['wishlist'] != null && userData['wishlist'] != "") { var userWishlist = userData['wishlist']; userWishlist = userWishlist.split(','); if (wishlist.length) { wishlist = wishlist.concat(userWishlist); $.ajax({ type: 'POST', url:opt.ajaxPost, data:{ action:'user_wishlist_update', user_id :userData['user_id'], wishlist :wishlist.join(','), } }); } else { wishlist = userWishlist; } wishlist = wishlist.unique(); highlightWishlist(wishlist,inWishlist); sessionStorage.removeItem(shopName); } else { if (typeof(ls) != 'undefined' && ls != null) { ls = ls.split(','); ls = ls.unique(); wishlist = ls; } $.ajax({ type: 'POST', url:opt.ajaxPost, data:{ action:'user_wishlist_update', user_id :userData['user_id'], wishlist :wishlist.join(','), } }) .done(function(response) { highlightWishlist(wishlist,inWishlist); sessionStorage.removeItem(shopName); }); } }, error: function(){ console.log('No user data returned'); } }); }
If User is Guest
Fetch wishlist from the session/local storage
else { if (typeof(ls) != 'undefined' && ls != null) { ls = ls.split(','); ls = ls.unique(); wishlist = ls; } }
As you may have noticed here we have double-AJAX and some helper functions. So first let’s create the actions of the AJAX requests, and after that I will explain our helper functions. I won’t describe in detail the AJAX functionality in WordPress, but if you are new to AJAX and WordPress, I highly recommend reading this amazing tutorial on it:
Plugins
A Primer on Ajax in the WordPress Frontend: Understanding the Process
Tom McFarlin
Our first AJAX request gets the user id and the user wishlist data from WordPress. This is done with a custom AJAX action added to the plugin code file:
// Get current user data function fetch_user_data() { if (is_user_logged_in()){ $current_user = wp_get_current_user(); $current_user_wishlist = get_user_meta( $current_user->ID, 'wishlist',true); echo json_encode(array('user_id' => $current_user->ID,'wishlist' => $current_user_wishlist)); } die(); } add_action( 'wp_ajax_fetch_user_data', 'fetch_user_data' ); add_action( 'wp_ajax_nopriv_fetch_user_data', 'fetch_user_data' );
The most important part here is the action name (fetch_user_data)–make sure it is the same for AJAX and for functions wp_ajax_fetch_user_data and wp_ajax_nopriv_fetch_user_data. Here we’re preparing JSON formatted data with user ID and user wishlist data.
Our next AJAX request updates the user wishlist if there were already wishlist items from session/local storage. Take a close look at the url option–see it is different.
The logic is the same as for the first action–the difference is that here we don’t return or echo any data, but we update the wishlist option for the current user.
function update_wishlist_ajax(){ if (isset($_POST["user_id"]) && !empty($_POST["user_id"])) { $user_id = $_POST["user_id"]; $user_obj = get_user_by('id', $user_id); if (!is_wp_error($user_obj) && is_object($user_obj)) { update_user_meta( $user_id, 'wishlist', $_POST["wishlist"]); } } die(); } add_action('admin_post_nopriv_user_wishlist_update', 'update_wishlist_ajax'); add_action('admin_post_user_wishlist_update', 'update_wishlist_ajax');
And if our user is a guest we will need to check if there are any wishlist details in the session/local storage.
Helper Functions
Before we move to the events part I want to explain our helper functions
Array.prototype.unique = function() { return this.filter(function (value, index, self) { return self.indexOf(value) === index; }); } function isInArray(value, array) {return array.indexOf(value) > -1;} function onWishlistComplete(target, title){ setTimeout(function(){ target .removeClass('loading') .addClass('active') .attr('title',title); },800); } function highlightWishlist(wishlist,title){ $('.wishlist-toggle').each(function(){ var $this = $(this); var currentProduct = $this.data('product'); currentProduct = currentProduct.toString(); if (isInArray(currentProduct,wishlist)) { $this.addClass('active').attr('title',title); } }); }
The first helper function makes the array unique, by removing duplicates, the second one checks if the given value is present in the given array. The next function executes when an item is added to the wishlist and the last one shows items that are in the wishlist.
Add Toggle
Now let’s add a click event to the wishlist toggle to power the actual functionality. On each toggle click event the animation is triggered and if the user is logged-in the wishlist update action fires with AJAX. If the user is a guest the item is added to the session/local storage.
Now if you go to the shop page, refresh the browser, and click on any wishlist toggle you will see it is working!
$('.wishlist-toggle').each(function(){ var $this = $(this); var currentProduct = $this.data('product'); currentProduct = currentProduct.toString(); if (!loggedIn && isInArray(currentProduct,wishlist)) { $this.addClass('active').attr('title',inWishlist); } $(this).on('click',function(e){ e.preventDefault(); if (!$this.hasClass('active') && !$this.hasClass('loading')) { $this.addClass('loading'); wishlist.push(currentProduct); wishlist = wishlist.unique(); if (loggedIn) { // get user ID if (userData['user_id']) { $.ajax({ type: 'POST', url:opt.ajaxPost, data:{ action:'user_wishlist_update', user_id :userData['user_id'], wishlist :wishlist.join(','), } }) .done(function(response) { onWishlistComplete($this, inWishlist); }) .fail(function(data) { alert(opt.error); }); } } else { sessionStorage.setItem(shopName, wishlist.toString()); onWishlistComplete($this, inWishlist); } } }); });
7. List Items in Wishlist Table
Now it is time to list our wishlist items in the wishlist table we created earlier.
Add the following code into main.js at the very bottom of our wrapper function:
setTimeout(function(){ if (wishlist.length) { restUrl += '?include='+wishlist.join(','); restUrl += '&per_page='+wishlist.length; $.ajax({ dataType: 'json', url:restUrl }) .done(function(response){ $('.wishlist-table').each(function(){ var $this = $(this); $.each(response,function(index,object){ $this.append('<tr data-product="'+object.id+'"><td><a class="wishlist-remove" href="#" title="'+opt.removeWishlist+'"></a>'+object.image+'</td><td>'+object.title["rendered"]+'</td><td>'+object.price+'</td><td>'+object.stock+'</td><td><a class="details" href="'+object.link+'">'+opt.buttonText+'</a></td></tr>'); }); }); }) .fail(function(response){ alert(opt.noWishlist); }) .always(function(response){ $('.wishlist-table').each(function(){ $(this).removeClass('loading'); }); }); } else { $('.wishlist-table').each(function(){ $(this).removeClass('loading'); }); } },1000);
Here we are using the WordPress REST API to get the products by ID in the wishlist array.
For each of the products we get we are adding a table row with the required data to display. We need the product image, title, stock status, button and price.
Here we have two options for the REST API:
using the WordPress REST API
using the WooCommerce REST API.
The difference here is that product data is already present in the Woocommerce REST API, but an API key is required. With the default WordPress REST API product data is absent by default, but can be added, and no API key is required. For such a simple task as a wishlist I don’t think that an API key is needed, so we will do it by extending the default WordPress REST API to return our product price, image code and the stock level.
Go to the main plugin file and at the very bottom add the following code:
// Extend REST API function rest_register_fields(){ register_rest_field('product', 'price', array( 'get_callback' => 'rest_price', 'update_callback' => null, 'schema' => null ) ); register_rest_field('product', 'stock', array( 'get_callback' => 'rest_stock', 'update_callback' => null, 'schema' => null ) ); register_rest_field('product', 'image', array( 'get_callback' => 'rest_img', 'update_callback' => null, 'schema' => null ) ); } add_action('rest_api_init','rest_register_fields'); function rest_price($object,$field_name,$request){ global $product; $id = $product->get_id(); if ($id == $object['id']) { return $product->get_price(); } } function rest_stock($object,$field_name,$request){ global $product; $id = $product->get_id(); if ($id == $object['id']) { return $product->get_stock_status(); } } function rest_img($object,$field_name,$request){ global $product; $id = $product->get_id(); if ($id == $object['id']) { return $product->get_image(); } } function maximum_api_filter($query_params) { $query_params['per_page']["maximum"]=100; return $query_params; } add_filter('rest_product_collection_params', 'maximum_api_filter');
All this does is create new fields for REST API and extends the maximum items limit per request. Again, if you are new to this subject I highly recommend reading this series.
For now, if you go to your wishlist table and refresh the page you will see the list of items that are added to your wishlist.
8. Removing Items From Wishlist
We are almost done; only the remove functionality remains. So let’s create that! Add the following code at the very bottom of the wrapper function in the main.js file
$(document).on('click', '.wishlist-remove', function(){ var $this = $(this); $this.closest('table').addClass('loading'); wishlist = []; $this.closest('table').find('tr').each(function(){ if ($(this).data('product') != $this.closest('tr').data('product')) { wishlist.push($(this).data('product')); if (loggedIn) { // get user ID if (userData['user_id']) { $.ajax({ type: 'POST', url:opt.ajaxPost, data:{ action:'user_wishlist_update', user_id :userData['user_id'], wishlist :wishlist.join(','), } }) .done(function(response) { $this.closest('table').removeClass('loading'); $this.closest('tr').remove(); }) .fail(function(data) { alert(opt.error); }); } } else { sessionStorage.setItem(shopName, wishlist.toString()); setTimeout(function(){ $this.closest('table').removeClass('loading'); $this.closest('tr').remove(); },500); } } }); });
Once the remove icon is clicked (make sure you have a remove.svg in the images folder, you can use whatever icon you want), we need to check if the user is logged-in. If so, we then remove the item ID from the wishlist using AJAX with the user_wishlist_update action. If the user is a guest we need to remove the item ID from the session/local storage.
Now go to your wishlist and refresh the page. Once you click on the remove icon your item will be removed from the wishlist.
Conclusion
That was quite a project! A simple, but comprehensive wishlist feature for your WooCommerce stores. You are free to use this plugin in any project; you can extend, modify it and make suggestions. I hope you liked it. Here is the link to the source files on GitHub. And here is the demo.
Learn More WooCommerce Theme Development
At Tuts+ we have a great collection of tutorials and courses to learn WooCommerce development. Check out these four great courses to get started!
WooCommerce
Up and Running With WooCommerce
Rachel McCollin
WordPress
Developing a WooCommerce Theme
Rachel McCollin
WordPress
Go Further With WooCommerce Themes
Rachel McCollin
WordPress
How to Make Your Theme WooCommerce Compatible
Rachel McCollin
by Karen Pogosyan via Envato Tuts+ Code https://ift.tt/2WTWfiG
1 note
·
View note
Text
PHP Introduction - An Ultimate Guide to Basics
PHP introduction tutorial comprises detailed information about what is this programming language, and how this intro can impart greater awareness to absolute beginners, so that they may think of initiating a web development career. Further, this basic and introductory tutorial is also helpful for advanced programmers, and it covers advanced PHP topics as well as basics and is based on the latest version PHP 8.2. 1.1. Why PHP is a Popular Language? - Basically, PHP is a server-side language that runs on the backend of a website or a server. - Also, PHP can be used separately or within an HTML markup to obtain the results. - The extensive usage of PHP in web applications and in the development of various CMS like WordPress, Joomla, Drupal, etc. - Therefore, its vast usage and applications make it quite a popular scripting language among developers and have a wide developer community. 1.2. What is PHP Programming Language? - First of all, PHP is a recursive backronym and stands for Hypertext PreProcessor. - The most stable release of the PHP script is 8.2.1 in 2023. - Secondly, PHP is one of the widely used programming languages and its popularity has spanned over the decades. - Also, there is no cost to using PHP and it is free to utilize. - Moreover, PHP code runs over popular databases like MySQL, Oracle, Microsoft SQL Server, etc. - Furthermore, PHP generates output for the user in the form of HTML markup. - Therefore, PHP is a handful tool for developing dynamic web pages. - Importantly, PHP is a powerful scripting language that runs on the server-side. 1.3. What are PHP Filename Extensions? Normally, when we save a PHP script in a file, it is given an extension to make it executable by the interpreter/compiler. There are many filename extensions of the PHP language that can be used for a file to make it executable by the interpreter. Plus, the most used PHP filename extension is .php. These PHP filename extensions are listed below: .php .phtml .php3 .php4 .php5 .php7 .phps .php-s .pht .phar 1.4. What is PHP-GTK? - PHP-GTK is a helpful PHP extension as it is useful in language binding implementation. - Language binding is a term, which is referred to linking two existing languages. - Here, PHP-GTK enables the developers to write PHP code in an object-oriented interface. - In simple words, PHP-GTK is the enhancement of PHP that empower developers to write cross-platform applications with a Graphical User Interface. - Also, PHP-GTK is available for both Windows and Linux users. Sometimes, a scripting language is considered a very high-level language for a high level of abstraction. This section will cover information about scripting languages, usage of scripting languages, and some of the most popular scripting languages. 2.1. What is a Scripting Language? - With each passing day, the world, which is already a global village, is emerging and evolving rapidly in almost every aspect of life due to technological advancements. - Hence, there is a necessity for automation, to perform certain jobs and resultantly lessen the workload. - Therefore, a scripting language plays its role in automating a runtime-system. - Consequently, the workload is shifted to the machine and especially the IT industry thereafter. - Importantly, a scripting language is interpreted rather than compiled to save time and boost performance. 2.2. What are the types of Scripting Languages? Basically, there are two types of scripting languages: a. Server-Side Scripting Language - These types of scripting languages use the resources of a remote server. - These scripts are compiled on a server and display the output in HTML form. - These types of scripts are helpful for clients/browsers. - Node.Js, PHP, Java, Python, Ruby, etc. are examples. b. Client-Side Scripting Language - These scripting languages run on the client side i.e. a browser. - Client-side scripting language solely relies on a browser, and there is no server involved. - Initially, the script is downloaded in the browser and then executed. - Client-side scripts are added to improve web page functionality. - Javascript, AJAX, Jquery, etc. are examples. 3.1. What is the Difference Between PHP and HTML? HTML is a web markup language and the acronym HTML stands for HyperText Markup Language. Whereas, PHP is a programming language that runs often on the server-side. The subsequent table summarizes the comparison between PHP and HTML. Language: PHP HTML Developed By: Zend Technologies W3C Type of Language: Programming Language Markup Language Usage: Server-side Front-end Code Type: Dynamic Static Ease of Learning: Relatively easy to learn Relatively hard to learn, includes logic Browser Compatibility: Compatible with all browsers Compatible with all browsers Initially Released: 1995 1991 Latest Stable Release: 2023 2017 Latest Version: 8.2.1 5.2 Open Source: Yes Yes Cross-Platform: Yes Yes Filename Extension: .php .html 3.2. What is the Difference Between PHP and ASP.NET? The acronym ASP stands for Active Server Pages. Further, ASP is a .NET framework and is developed by Microsoft. Let's examine what is the difference between PHP and ASP.NET. The below table summarizes the comparison of PHP with ASP.NET. Language: PHP ASP.NET Developed By: Zend Technologies Microsoft Corporation Initially Released: 1995 2002 Latest Stable Release: 2020 2019 Latest Version: 8.2.1 4.8 Hosting Support: All Hosting Servers Support PHP Need Dedicated Server for ASP.NET License: PHP License Apache License 2.0 Open Source: Yes No HTML Integration: Easy Complex Extension to Other Language: Yes No 4.1. How to Start Coding in PHP? Due to the reputation of the PHP programming language, it has become the developer's prime choice over the past years. As a noob developer, there is a necessity to have some know-how of fundamental web languages before commencing with PHP. These include the following: - HTML Language - CSS Language - JavaScript Language However, only HTML is sufficient for starting programming with PHP. 4.2. Why do Developers Like to Code in PHP Language? Considering PHP is so popular among developers, there is a reason for that. Beneath are some of the features of PHP that make it so much popular. - Easy to use - Efficient in execution - More reliable security at server-side - Too much flexibility - Similarity with other languages Popular PHP Applications Following are some popular PHP applications that give it so much fame: - Facebook: The largest social media website is coded in PHP makes it most compelling. - WordPress: Approximately 30% of the websites on the internet are hosted by popular CMS WordPress, which is primarily a PHP framework. 4.3. What are the Benefits of Using PHP? Due to the robust programming methodologies, PHP is not confined to producing HTML solely. Preferably, it can display images, videos, pdf files, etc. Following are certain PHP benefits that are adequate to take PHP as a programmer's primary choice: - Nearly, all web servers, operating systems, and databases can run the PHP script. - When executed on the server-side, it generates dynamic content. - PHP gives many varieties of output like text, HTML, JSON, image, binary data, JSON, etc. - It can perform several operations on the server like creating, opening, writing, reading, and deleting files. - PHP has its reputation due to data collection using HTML forms. - It can encrypt data to make it secure and safe. - Also, Cookies can be sent and received using a PHP script. - PHP can add, delete, and edit the database. - Further, It supports both the Command-line interface (CLI) and the Graphical User Interface (GUI). - Too many frameworks of PHP are available in the market to help developers in Rapid Application Development (RAD). 4.4. Write "Hello World" PHP Program It is important to know that, there are two methods to integrate PHP and HTML. One way is to write PHP in HTML markup, whereas, the other way is to write HTML within the PHP script. Examine the subsequent "Hello World PHP Program" in two different ways to understand it more vividly. 4.5. Output of "Hello World" PHP Program Both of the above examples will produce the same result on the screen. The server process the PHP code and returns only HTML markup to the browser. The output of this hello world PHP program is as follows: 4.6. An Advanced PHP Program The following example is another PHP program. It will check the browser of the user and display it on the screen. 4.7. Output of Advanced PHP Program The above line of PHP script will display the output on the screen similar to the following output. 4.8. What's Next? Hopefully, this intro to PHP tutorial covered all the basics and knowledge for beginners as well as advanced web developers. Navigate to the next tutorials to enhance your PHP skills and gain in-depth cognition. Read the full article
0 notes