One place for hosting & domains

      How To Store and Retrieve Data in MariaDB Using Python on Ubuntu 18.04

      The author selected the Tech Education Fund to receive a donation as part of the Write for DOnations program.


      MariaDB is an open source version of the popular MySQL relational database management system (DBMS) with a SQL interface for accessing and managing data. It is highly reliable and easy to administer, which are essential qualities of a DBMS capable of serving modern applications. With Python’s growing popularity in technologies like artificial intelligence and machine learning, MariaDB makes a good option for a database server for Python.

      In this tutorial, you will connect a Python application to a database server using the MySQL connector. This module allows you to make queries on the database server from within your application. You’ll set up MariaDB for a Python environment on Ubuntu 18.04 and write a Python script that connects to and executes queries on MariaDB.


      Before you begin this guide, you will need the following:

      Step 1 — Preparing and Installing

      In this step, you’ll create a database and a table in MariaDB.

      First, open your terminal and enter the MariaDB shell from the terminal with the following command:

      Once you’re in the MariaDB shell, your terminal prompt will change. In this tutorial, you’ll write Python to connect to an example employee database named workplace and a table named employees.

      Start by creating the workplace database:

      • CREATE DATABASE workplace;

      Next, tell MariaDB to use workplace as your current database:

      You will receive the following output, which means that every query you run after this will take effect in the workplace database:


      Database changed

      Next, create the employees table:

      • CREATE TABLE employees (first_name CHAR(35), last_name CHAR(35));

      In the table schema, the parameters first_name and a last_name are specified as character strings (CHAR) with a maximum length of 35.

      Following this, exit the MariaDB shell:

      Back in the terminal, export your MariaDB authorization credentials as environment variables:

      • export username="username"
      • export password="password"

      This technique allows you to avoid adding credentials in plain text within your script.

      You’ve set up your environment for the project. Next, you’ll begin writing your script and connect to your database.

      Step 2 — Connecting to Your Database

      In this step, you will install the MySQL Connector and set up the database.

      In your terminal, run the following command to install the Connector:

      • pip3 install mysql-connector-python

      pip is the standard package manager for Python. mysql-connector-python is the database connector Python module.

      Once you’ve successfully installed the connector, create and open a new file Python file:

      In the opened file, import the os module and the mysql.connector module using the import keyword:

      import os
      import mysql.connector as database

      The as keyword here means that mysql.connector will be referenced as database in the rest of the code.

      Next, initialize the authorization credentials you exported as Python variables:

      . . .
      username = os.environ.get("username")
      password = os.environ.get("password")

      Follow up and establish a database connection using the connect() method provided by database. The method takes a series of named arguments specifying your client credentials:

      . . .
      connection = database.connect(

      You declare a variable named connection that holds the call to the database.connect() method. Inside the method, you assign values to the user, password, host, and database arguments. For user and password, you will reference your MariaDB authorization credentials. The host will be localhost by default if you are running the database on the same system.

      Lastly, call the cursor() method on the connection to obtain the database cursor:

      . . .
      cursor = connection.cursor()

      A cursor is a database object that retrieves and also updates data, one row at a time, from a set of data.

      Leave your file open for the next step.

      Now you can connect to MariaDB with your credentials; next, you will add entries to your database using your script.

      Step 3 — Adding Data

      Using the execute() method on the database cursor, you will add entries to your database in this step.

      Define a function add_data() to accept the first and last names of an employee as arguments. Inside the function, create a try/except block. Add the following code following your cursor object:

      . . .
      def add_data(first_name, last_name):
              statement = "INSERT INTO employees (first_name,last_name) VALUES (%s, %s)"
              data = (first_name, last_name)
              cursor.execute(statement, data)
              print("Successfully added entry to database")
          except database.Error as e:
              print(f"Error adding entry to database: {e}")

      You use the try and except block to catch and handle exceptions (events or errors) that disrupt the normal flow of program execution.

      Under the try block, you declare statement as a variable holding your INSERT SQL statement. The statement tells MariaDB to add to the columns first_name and last_name.

      The code syntax accepts data as parameters that reduce the chances of SQL injection. Prepared statements with parameters ensure that only given parameters are securely passed to the database as intended. Parameters are generally not injectable.

      Next you declare data as a tuple with the arguments received from the add_data function. Proceed to run the execute() method on your cursor object by passing the SQL statement and the data. After calling the execute() method, you call the commit() method on the connection to permanently save the inserted data.

      Finally, you print out a success message if this succeeds.

      In the except block, which only executes when there’s an exception, you declare database.Error as e. This variable will hold information about the type of exception or what event happened when the script breaks. You then proceed to print out an error message formatted with e to end the block using an f-string.

      After adding data to the database, you’ll next want to retrieve it. The next step will take you through the process of retrieving data.

      Step 4 — Retrieving Data

      In this step, you will write a SQL query within your Python code to retrieve data from your database.

      Using the same execute() method on the database cursor, you can retrieve a database entry.

      Define a function get_data() to accept the last name of an employee as an argument, which you will call with the execute() method with the SELECT SQL query to locate the exact row:

      . . .
      def get_data(last_name):
            statement = "SELECT first_name, last_name FROM employees WHERE last_name=%s"
            data = (last_name,)
            cursor.execute(statement, data)
            for (first_name, last_name) in cursor:
              print(f"Successfully retrieved {first_name}, {last_name}")
          except database.Error as e:
            print(f"Error retrieving entry from database: {e}")

      Under the try block, you declare statement as a variable holding your SELECT SQL statement. The statement tells MariaDB to retrieve the columns first_name and last_name from the employees table when a specific last name is matched.

      Again, you use parameters to reduce the chances of SQL injection.

      Smilarly to the last function, you declare data as a tuple with last_name followed by a comma. Proceed to run the execute() method on the cursor object by passing the SQL statement and the data. Using a for loop, you iterate through the returned elements in the cursor and then print out if there are any successful matches.

      In the except block, which only executes when there is an exception, declare database.Error as e. This variable will hold information about the type of exception that occurs. You then proceed to print out an error message formatted with e to end the block.

      In the final step, you will execute your script by calling the defined functions.

      Step 5 — Running Your Script

      In this step, you will write the final piece of code to make your script executable and run it from your terminal.

      Complete your script by calling add_data() and get_data() with sample data (strings) to verify that your code is working as expected.

      If you would like to add multiple entries, you can call add_data() with further sample names of your choice.

      Once you finish working with the database make sure that you close the connection to avoid wasting resources:

      import os
      import mysql.connector as database
      username = os.environ.get("username")
      password = os.environ.get("password")
      connection = database.connect(
      cursor = connection.cursor()
      def add_data(first_name, last_name):
          statement = "INSERT INTO employees (first_name,last_name) VALUES (%s, %s)"
          data = (first_name, last_name)
            cursor.execute(statement, data)
          print("Successfully added entry to database")
          except database.Error as e:
          print(f"Error adding entry to database: {e}")
      def get_data(last_name):
            statement = "SELECT first_name, last_name FROM employees WHERE last_name=%s"
            data = (last_name,)
            cursor.execute(statement, data)
            for (first_name, last_name) in cursor:
              print(f"Successfully retrieved {first_name}, {last_name}")
          except database.Error as e:
            print(f"Error retrieving entry from database: {e}")
      add_data("Kofi", "Doe")

      Make sure you have indented your code correctly to avoid errors.

      In the same directory, you created the file, run your script with:

      You will receive the following output:


      Successfully added entry to database Successfully retrieved Kofi, Doe

      Finally, return to MariaDB to confirm you have successfully added your entries.

      Open up the MariaDB prompt from your terminal:

      Next, tell MariaDB to switch to and use the workplace database:

      After you get the success message Database changed, proceed to query for all entries in the employees table:

      You output will be similar to the following:


      +------------+-----------+ | first_name | last_name | +------------+-----------+ | Kofi | Doe | +------------+-----------+ 1 row in set (0.00 sec)

      Putting it all together, you’ve written a script that saves and retrieves information from a MariaDB database.

      You started by importing the necessary libraries. You used mysql-connector to connect to the database and os to retrieve authorization credentials from the environment. On the database connection, you retrieved the cursor to carry out queries and structured your code into add_data and get_data functions. With your functions, you inserted data into and retrieved data from the database.

      If you wish to implement deletion, you can build a similar function with the necessary declarations, statements, and calls.


      You have successfully set up a database connection to MariaDB using a Python script on Ubuntu 18.04. From here, you could use similar code in any of your Python projects in which you need to store data in a database. This guide may also be helpful for other relational databases that were developed out of MySQL.

      For more on how to accomplish your projects with Python, check out other community tutorials on Python.

      Source link

      How To Use the MySQL BLOB Data Type to Store Images with PHP on Ubuntu 18.04

      The author selected Girls Who Code to receive a donation as part of the Write for DOnations program.


      A Binary Large Object (BLOB) is a MySQL data type that can store binary data such as images, multimedia, and PDF files.

      When creating applications that require a tightly-coupled database where images should be in sync with related data (for example, an employee portal, a student database, or a financial application), you might find it convenient to store images such as students’ passport photos and signatures in a MySQL database alongside other related information.

      This is where the MySQL BLOB data type comes in. This programming approach eliminates the need for creating a separate file system for storing images. The scheme also centralizes the database, making it more portable and secure because the data is isolated from the file system. Creating backups is also more seamless since you can create a single MySQL dump file that contains all your data.

      Retrieving data is faster, and when creating records you can be sure that data validation rules and referential integrity are maintained especially when using MySQL transactions.

      In this tutorial, you will use the MySQL BLOB data type to store images with PHP on Ubuntu 18.04.


      To follow along with this guide, you will need the following:

      Step 1 — Creating a Database

      You’ll start off by creating a sample database for your project. To do this, SSH in to your server and then run the following command to log in to your MySQL server as root:

      Enter the root password of your MySQL database and hit ENTER to continue.

      Then, run the following command to create a database. In this tutorial we’ll name it test_company:

      • CREATE DATABASE test_company;

      Once the database is created, you will see the following output:


      Query OK, 1 row affected (0.01 sec)

      Next, create a test_user account on the MySQL server and remember to replace PASSWORD with a strong password:

      • CREATE USER 'test_user'@'localhost' IDENTIFIED BY 'PASSWORD';

      You’ll see the following output:


      Query OK, 0 rows affected (0.01 sec)

      To grant test_user full privileges on the test_company database, run:

      • GRANT ALL PRIVILEGES ON test_company.* TO 'test_user'@'localhost';

      Make sure you get the following output:


      Query OK, 0 rows affected (0.01 sec)

      Finally, flush the privileges table in order for MySQL to reload the permissions:

      Ensure you see the following output:


      Query OK, 0 rows affected (0.01 sec)

      Now that the test_company database and test_user are ready, you’ll move on to creating a products table for storing sample products. You’ll use this table later to insert and retrieve records to demonstrate how MySQL BLOB works.

      Log out from the MySQL server:

      Then, log back in again with the credentials of the test_user that you created:

      When prompted, enter the password for the test_user and hit ENTER to continue. Next, switch to the test_company database by typing the following:

      Once the test_company database is selected, MySQL will display:


      Database changed

      Next, create a products table by running:

      • CREATE TABLE `products` (product_id BIGINT PRIMARY KEY AUTO_INCREMENT, product_name VARCHAR(50), price DOUBLE, product_image BLOB) ENGINE = InnoDB;

      This command creates a table named products. The table has four columns:

      • product_id: This column uses a BIGINT data type in order to accommodate a large list of products up to a maximum of 2⁶³-1 items. You’ve marked the column as PRIMARY KEY to uniquely identify products. In order for MySQL to handle the generation of new identifiers for inserted columns, you have used the keyword AUTO_INCREMENT.

      • product_name: This column holds the names of the products. You’ve used the VARCHAR data type since this field will generally handle alphanumerics up to a maximum of 50 characters—the limit of 50 is just a hypothetical value used for the purpose of this tutorial.

      • price: For demonstration purposes, your products table contains the price column to store the retail price of products. Since some products may have floating values (for example, 23.69, 45.36, 102.99), you’ve used the DOUBLE data type.

      • product_image: This column uses a BLOB data type to store the actual binary data of the products’ images.

      You’ve used the InnoDB storage ENGINE for the table to support a wide range of features including MySQL transactions. After executing this for creating the products table, you’ll see the following output:


      Query OK, 0 rows affected (0.03 sec)

      Log out from your MySQL server:

      You will get the following output



      The products table is now ready to store some records including products’ images and you’ll populate it with some products in the next step.

      Step 2 — Creating PHP Scripts for Connecting and Populating the Database

      In this step, you’ll create a PHP script that will connect to the MySQL database that you created in Step 1. The script will prepare three sample products and insert them into the products table.

      To create the PHP code, open a new file with your text editor:

      • sudo nano /var/www/html/config.php

      Then, enter the following information into the file and replace PASSWORD with the test_user password that you created in Step 1:


      define('DB_NAME', 'test_company');
      define('DB_USER', 'test_user');
      define('DB_PASSWORD', 'PASSWORD');
      define('DB_HOST', 'localhost');
      $pdo = new PDO("mysql:host=" . DB_HOST . "; dbname=" . DB_NAME, DB_USER, DB_PASSWORD);
      $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);

      Save and close the file.

      In this file, you’ve used four PHP constants to connect to the MySQL database that you created in Step 1:

      • DB_NAME : This constant holds the name of the test_company database.

      • DB_USER : This variable holds the test_user username.

      • DB_PASSWORD : This constant stores the MySQL PASSWORD of the test_user account.

      • DB_HOST: This represents the server where the database resides. In this case, you are using the localhost server.

      The following line in your file initiates a PHP Data Object (PDO) and connects to the MySQL database:

      $pdo = new PDO("mysql:host=" . DB_HOST . "; dbname=" . DB_NAME, DB_USER, DB_PASSWORD);

      Toward the end of the file, you’ve set a couple of PDO attributes:

      • ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION: This attribute instructs PDO to throw an exception that can be logged for debugging purposes.
      • ATTR_EMULATE_PREPARES, false: This option increases security by telling the MySQL database engine to do the prepare instead of PDO.

      You’ll include the /var/www/html/config.php file in two PHP scripts that you will create next for inserting and retrieving records respectively.

      First, create the /var/www/html/insert_products.php PHP script for inserting records to the products table:

      • sudo nano /var/www/html/insert_products.php

      Then, add the following information into the /var/www/html/insert_products.php file:


      require_once 'config.php';
      $products = [];
      $products[] = [
                    'product_name' => 'VIRTUAL SERVERS',
                    'price' => 5,
                    'product_image' => file_get_contents("")
      $products[] = [
                    'product_name' => 'MANAGED KUBERNETES',
                    'price' => 30,
                    'product_image' => file_get_contents("")
      $products[] = [
                    'product_name' => 'MySQL DATABASES',
                    'price' => 15,
                    'product_image' => file_get_contents("" )
      $sql = "INSERT INTO products(product_name, price, product_image) VALUES (:product_name, :price, :product_image)";
      foreach ($products as $product) {
          $stmt = $pdo->prepare($sql);
      echo "Records inserted successfully";

      Save and close the file.

      In the file, you’ve included the config.php file at the top. This is the first file you created for defining the database variables and connecting to the database. The file also initiates a PDO object and stores it in a $pdo variable.

      Next, you’ve created an array of the products’ data to be inserted into the database. Apart from the product_name and price, which are prepared as strings and numeric values respectively, the script uses PHP’s in-built file_get_contents function to read images from an external source and pass them as strings to the product_image column.

      Next, you have prepared an SQL statement and used the PHP foreach{...} statement to insert each product into the database.

      To execute the /var/www/html/insert_products.php file, run it in your browser window using the following URL. Remember to replace your-server-IP with the public IP address of your server:


      After executing the file, you’ll see a success message in your browser confirming records were inserted into the database.

      A success message showing that records were inserted to database

      You have successfully inserted three records containing product images into the products table. In the next step, you’ll create a PHP script for retrieving these records and displaying them in your browser.

      Step 3 — Displaying Products’ Information From the MySQL Database

      With the products’ information and images in the database, you’re now going to code another PHP script that queries and displays the products’ information in an HTML table on your browser.

      To create the file, type the following:

      • sudo nano /var/www/html/display_products.php

      Then, enter the following information into the file:


        <title>Using BLOB and MySQL</title>
        require_once 'config.php';
        $sql = "SELECT * FROM products";
        $stmt = $pdo->prepare($sql);
        <table border = '1' align = 'center'> <caption>Products Database</caption>
            <th>Product Id</th>
            <th>Product Name</th>
            <th>Product Image</th>
        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
            echo '<tr>';
            echo '<td>' . $row['product_id'] . '</td>';
            echo '<td>' . $row['product_name'] . '</td>';
            echo '<td>' . $row['price'] . '</td>';
            echo '<td>' .
            '<img src = "data:image/png;base64,' . base64_encode($row['product_image']) . '" width = "50px" height = "50px"/>'
            . '</td>';
            echo '</tr>';

      Save the changes to the file and close it.

      Here you’ve again included the config.php file in order to connect to the database. Then, you have prepared and executed an SQL statement using PDO to retrieve all items from the products table using the SELECT * FROM products command.

      Next, you have created an HTML table and populated it with the products’ data using the PHP while() {...} statement. The line $row = $stmt->fetch(PDO::FETCH_ASSOC) queries the database and stores the result in the $row variable as a multi-dimensional array, which you have then displayed in an HTML table column using the $row['column_name'] syntax.

      The images from the product_image column are enclosed inside the <img src = ""> tags. You’ve used the width and height attributes to resize the images to a smaller size that can fit in the HTML table column.

      In order to convert the data held by the BLOB data type back to images, you’ve used the in-built PHP base64_encode function and the following syntax for the Data URI scheme:

      data:media_type;base64, base_64_encoded_data

      In this case, the image/png is the media_type and the Base64 encoded string from the product_image column is the base_64_encoded_data.

      Next, execute the display_products.php file in a web browser by typing the following address:


      After running the display_products.php file in your browser, you will see an HTML table with a list of products and associated images.

      List of products from MySQL database

      This confirms that the PHP script for retrieving images from MySQL is working as expected.


      In this guide, you used the MySQL BLOB data type to store and display images with PHP on Ubuntu 18.04. You’ve also seen the basic advantages of storing images in a database as opposed to storing them in a file system. These include portability, security, and ease of backup. If you are building an application such as a students’ portal or employees’ database that requires information and related images to be stored together, then this technology can be of great use to you.

      For more information about the supported data types in MySQL follow the MySQL Data Types guide. If you’re interested in further content relating to MySQL and PHP, check out the following tutorials:

      Source link

      9 Steps to Build an Online Store and Become Your Own Boss in 2019

      While traditional careers have their benefits, there’s something very appealing about being your own boss. You can work whenever, however, and wherever you want to while still pursuing your passion. The tricky part is knowing how to get started.

      With accessible and easy-to-use tools such as WordPress and WooCommerce, setting up shop online is relatively simple. By launching an e-commerce store, you can take your product ideas to the web and access the vast pool of customers available there.

      This article will walk you through the steps to build your online store with WordPress and WooCommerce and become your own boss in no time. Let’s go!

      Your Store Deserves WooCommerce Hosting

      Sell anything, anywhere, anytime on the world’s biggest eCommerce platform.

      9 Steps to Build an Online Store and Become Your Own Boss

      The very first thing you’ll need to start an online store is a product customers will want to buy. We can’t help you with that, unfortunately — your idea has to be all your own! You’ll also need a way to manufacture your product, either by doing it yourself, hiring a company to do it, or some combination of the two.

      Once you’re done, you’ll be ready to set up your online store and start selling your merchandise, which is where the steps below will come in handy.

      Step 1: Secure Your Web Hosting and Domain Name

      The first two things you need to start any kind of website are a hosting provider and a domain name. Your hosting provider will store your website’s files, while your domain name provides an address where customers can find your store.

      If you’re building a WordPress site (which we recommend), you might also want to consider WordPress hosting. These types of plans are explicitly geared towards the platform, and the servers they run on will be optimized.

      Our shared WordPress hosting plans, for example, are ideal for new WordPress sites. You’ll have access to our 24/7 tech support team, and plans are cost-effective, starting at just $2.59 per month for a single site.

      DreamHost’s Shared WordPress Hosting page.

      What’s more, we can also help you register your domain name. You can quickly check the availability of your desired web address, then register it once you’ve found the perfect fit.

      DreamHost’s domain name search.

      Simply fill in some information to complete the process. Domains usually start at $11.99, but if you’re also hosting your site with a shared WordPress plan, you’ll get yours for free.

      Step 2: Set Up WordPress and WooCommerce

      Regardless of your current host, a WordPress hosting plan likely comes with the platform pre-installed or with a one-click installation option. In some cases, you may need to install WordPress manually.

      Next, you’ll need to set up WooCommerce — a premiere e-commerce solution for WordPress (we’ve compared it to other competitors and think it’s the best ecommerce platform available).

      The first step is to install and activate the WooCommerce plugin.

      The WooCommerce plugin.

      Once this is complete, you’ll be prompted to configure your store using the onboarding wizard — fill in the fields as best you can now, or come back to this step later.

      Step 3: Identify Your ‘Value Proposition’

      Before you begin creating content for your e-commerce business, consider identifying and writing out your value proposition. This is simply a statement explaining the mission and value of your business and products.

      Two of the most important questions your value proposition should answer are:

      1. What problem does my product solve for customers?
      2. What makes my approach to this problem unique compared to other similar businesses?

      Establishing your value proposition now should help you create content later. Also, any copy, product, or long-form content (such as a blog post) should reflect the values you identified in your proposition.

      We’d also suggest sharing your value proposition with customers on your website. Most companies do this on an About page or as a ‘Mission Statement.’ Here’s ours as an example:

      The DreamHost About page.

      Sharing your values with customers can help demonstrate why your product is relevant to them. Plus, you might win over customers who might have otherwise purchased from your competition.

      Step 4: Create Your Product Pages

      Now you’re ready to go back to setting up your online store. Navigate to Products > Add New within WordPress to start adding your first item. There are a lot of settings to consider here, but your priority should be your product photos and description.

      Taking Quality Product Photos

      Showcasing your products in their (literal) best light is crucial. Unprofessional, low-quality photos make your site seem untrustworthy, which will discourage customers from opening their wallet.

      As such, make sure your product photos are well-lit and taken in front of a clean background. If you can, take pictures from a variety of angles, and include some close-ups of unique details to help catch customers’ eyes.

      A product photo of a throw pillow from Wayfair.

      Once you have your product photos, make sure to optimize them with a plugin such as ShortPixel or Optimole before uploading them to your site. This will help prevent large media files from slowing your site down.

      Writing Captivating Product Descriptions

      You’ll also want to craft your product descriptions carefully, to help convince site visitors to become paying customers. Keep your value proposition in mind when you’re writing, and make sure to point out information about how the product will benefit customers.

      A product description for a throw pillow from Wayfair.

      It’s vital to make your description easy to scan, as ‘skimming’ content has become more popular over the years. Keeping paragraphs short, while using formatting techniques such as bullet points and subheadings, can convey more information than a brutal wall of text.

      Specifying Product Data

      Finally, for this section, you’ll want to configure the settings in the Product Data section of the product editor. Here you’ll set your product’s price, add a SKU number and shipping information, specify if it comes in any variations (e.g., other colors or sizes), and more.

      The product data section of the WooCommerce Product Editor.

      Take your time with these, as they’re an essential aspect of your store and business. Once you have the basics down, you may want to consider setting up Linked Products to help cross-sell other store items and enable reviews to add some social proof to your site.

      Step 5: Configure Your Tax Settings

      In the U.S., each state has laws regarding sales tax for internet-based retailers. It’s not a bad idea to talk with a tax attorney before your business gets up and running, but at the very least, you should familiarize yourself with the laws in your area.

      To set up sales tax for your products in WooCommerce, navigate to WooCommerce > Settings > General within WordPress. Make sure the Enable taxes setting is checked, then save your changes.

      The Enable taxes setting in WooCommerce.

      If there wasn’t one before, you should now see a Tax setting tab at the top of your WooCommerce Settings page. Click on it, then configure the settings on the page.

      You can determine whether your prices will automatically include tax at checkout and what information WooCommerce should use to calculate tax for each product. It’s also possible to add Standard, Reduced, and Zero tax rates if needed.

      Step 6: Specify Your Shipping Methods

      Shipping is a make-or-break aspect of running a store. As such, in the Shipping settings tab, you can add practically as many options as you want to implement a delivery strategy.

      If you’re going to make your products available in a wide range of locations, you might want to create ‘shipping zones.’

      They essentially let you offer different rates to customers depending on where they’re located. If you also want to charge extra for international shipping, you can do so here.

      Step 7: Decide Which Payment Gateway to Offer

      In the Payments settings tab, you can specify how customers can pay for their products. By default, WooCommerce will set up Stripe and PayPal vendors for you.

      The Payment Methods settings in WooCommerce.

      However, you can add additional gateways — including popular solutions such as Square and Amazon Pay — with WooCommerce extensions. In addition, you can enable your customers to pay with a check, cash, or by bank transfer.

      The gateways you decide to offer are ultimately up to you, based on familiarity, ease of use, and transaction fees. However, it’s also important to consider your customers, as these criteria are also their primary concerns. As such, gateways such as PayPal are usually a given.

      Step 8: Run Through Your WooCommerce Search Engine Optimization (SEO) Checklist

      You’re almost ready to welcome customers to your store, but first, they need to be able to find it. SEO is the answer. By optimizing your content for search engines, you’ll make it more likely customers can find you while searching for products online.

      As with many site aspects, WordPress plugins can help. Yoast SEO is a highly rated and effective plugin that can help manage on-page SEO factors such as keyword usage, permalinks, and readability.

      The Yoast SEO plugin from the WordPress Plugin Directory.

      If you want something a little more specialized, you can also look into the Yoast WooCommerce SEO plugin.

      The Yoast WooCommerce SEO plugin.

      It’s better suited to WooCommerce than the free version, and can also help promote your products on social media. At $49 per year, it’s cost-effective and may be a solid investment, especially if it helps to bring in a few more organic customers via search engine.

      Step 9: Publish and Promote Your E-Commerce Website

      While you can keep refining your site, you’ll want to publish at this point — think of it as laying down a ‘marker.’ You’ll also want to make sure customers know who you are and what you do. Promoting your site on social media and through email marketing campaigns can help get you started.

      Fortunately, there are a variety of WooCommerce extensions available to help. You can choose popular services such as Drip, MailChimp, and even Instagram to promote your products to followers and subscribers.

      The WooCommerce Instagram extension.

      Marketing will be an ongoing responsibility, so investing in some tools to help you streamline your efforts will be worth it in the long run. The extensions mentioned above range from free to $79 per year. You can also search the WordPress Plugin Directory for more free solutions, although you may find functionality lacks depending on the plugin.

      Building an Online Store

      No one said becoming your own boss was easy, and there’s a lot of work that goes into starting a brand new business. However, WordPress and WooCommerce can simplify many of the tasks required to get your e-commerce site up and running.

      Ready to set up an online shop? Our WooCommerce hosting packages make it easy to sell anything, anywhere, anytime on the world’s biggest eCommerce platform.

      Source link