[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]
by Madiha via Digital Information World
"Mr Branding" is a blog based on RSS for everything related to website branding and website design, it collects its posts from many sites in order to facilitate the updating to the latest technology.
To suggest any source, please contact me: Taha.baba@consultant.com
Do you want more views on your YouTube videos? Wondering how to get more people to click on your YouTube suggested videos? In this article, you’ll discover how your YouTube click-through rate (CTR) impacts video views and find six steps to improve your YouTube click-through rate. Why YouTube Click-Through Rate Is Important Five hundred hours […]
The post How to Improve Your YouTube Video Views appeared first on Social Media Marketing | Social Media Examiner.
In programming, modules are self-contained units of functionality that can be shared and reused across projects. They make our lives as developers easier, as we can use them to augment our applications with functionality that we haven't had to write ourselves. They also allow us to organize and decouple our code, leading to applications that are easier to understand, debug and maintain.
In this article, I'll examine how to work with modules in Node.js, focusing on how to export and consume them.
As JavaScript originally had no concept of modules, a variety of competing formats have emerged over time. Here's a list of the main ones to be aware of:
define function to define modules.require and module.exports to define dependencies and modules. The npm ecosystem is built upon this format.export keyword to export a module's public API and an import keyword to import it.Please be aware that this article deals solely with the CommonJS format, the standard in Node.js. If you'd like to read into any of the other formats, I recommend this article, by SitePoint author Jurgen Van de Moere.
Node.js comes with a set of built-in modules that we can use in our code without having to install them. To do this, we need to require the module using the require keyword and assign the result to a variable. This can then be used to invoke any methods the module exposes.
For example, to list out the contents of a directory, you can use the file system module and its readdir method:
const fs = require('fs');
const folderPath = '/home/jim/Desktop/';
fs.readdir(folderPath, (err, files) => {
files.forEach(file => {
console.log(file);
});
});
Note that in CommonJS, modules are loaded synchronously and processed in the order they occur.
Now let's look at how to create our own module and export it for use elsewhere in our program. Start off by creating a user.js file and adding the following:
const getName = () => {
return 'Jim';
};
exports.getName = getName;
Now create an index.js file in the same folder and add this:
const user = require('./user');
console.log(`User: ${user.getName()}`);
Run the program using node index.js and you should see the following output to the terminal:
User: Jim
So what has gone on here? Well, if you look at the user.js file, you'll notice that we're defining a getName function, then using the exports keyword to make it available for import elsewhere. Then in the index.js file, we're importing this function and executing it. Also notice that in the require statement, the module name is prefixed with ./, as it's a local file. Also note that there's no need to add the file extension.
We can export multiple methods and values in the same way:
const getName = () => {
return 'Jim';
};
const getLocation = () => {
return 'Munich';
};
const dateOfBirth = '12.01.1982';
exports.getName = getName;
exports.getLocation = getLocation;
exports.dob = dateOfBirth;
And in index.js:
const user = require('./user');
console.log(
`${user.getName()} lives in ${user.getLocation()} and was born on ${user.dob}.`
);
The code above produces this:
Jim lives in Munich and was born on 12.01.1982.
Notice how the name we give the exported dateOfBirth variable can be anything we fancy (dob in this case). It doesn't have to be the same as the original variable name.
I should also mention that it's possible to export methods and values as you go, not just at the end of the file.
For example:
exports.getName = () => {
return 'Jim';
};
exports.getLocation = () => {
return 'Munich';
};
exports.dob = '12.01.1982';
And thanks to destructuring assignment, we can cherry-pick what we want to import:
const { getName, dob } = require('./user');
console.log(
`${getName()} was born on ${dob}.`
);
As you might expect, this logs:
Jim was born on 12.01.1982.
The post Understanding module.exports and exports in Node.js appeared first on SitePoint.

In this post, we’re going to discuss the Subscriptio WooCommerce subscriptions plugin which allows you to sell subscriptions on your WordPress store. More importantly, it adds recurring payments capability which allows you to sell different types of subscriptions or memberships.
If you’re in the field of eCommerce and you’re looking for a way to sell subscription products on your store, you’re at the right place! Selling subscription products on your store is something which is going to take a whole lot of effort: from configuring subscriptions to handling automatic payments for those products. Along with the checkout of regular products, you’ll have to pay attention to subscriptions that have its own challenges.
And thus, it would be great if you could find an extension or plugin which is all-in-one and provides all the necessary features that we’ve just discussed. When it comes to setting up subscriptions in WordPress, there are thousands of extensions and scripts available online. Alongside, you’ll also find commercial options that provide ready-to-use features and extended support. In the case of commercial options, you should also expect quality code, bug fixes, and new enhancements.
Today, we’re going to explore the Subscriptio—WooCommerce Subscriptions plugin which is one of the most popular plugin for selling subscriptions in the WooCommerce category. It allows you to sell different kinds of subscriptions and collect recurring payments automatically once the order is placed for such products. Along with the payment reminders, it is an all-in-one plugin one for those looking to set up recurring payments for a WooCommerce store.
Let’s have a look at a couple of important features this plugin brings:
In fact, this plugin provides a complete set of features to fulfill all the requirements of a complete subscription checkout flow on a typical eCommerce store, and that too at a very reasonable price!
As it’s a WooCommerce specific extension, I assume that you’ve installed WooCommerce on your WordPress site and you’re familiar with it. We’re not going to get into the specifics of WooCommerce while setting up the subscriptions.
[woocommerce content]
Let’s assume that you are selling different types of magazines online. Along with the regular magazines, users can also purchase subscriptions for it at a discounted price. In our case, we’re going to sell half-yearly and yearly subscriptions. In this way, you could also boost up sales, since users would be tempted to buy subscriptions if they are regular users.
When a user purchases a product with subscription from the front-end, it’ll create a subscription order, and thus it’ll send automatic payment reminders at every month. If a user pays with the payment method which supports subscriptions, we can attempt to process automatic payments as well.
Throughout the rest of this tutorial, we’ll explore different aspects of this plugin while moving closer to our goal. Next, we'll see how to download and install this plugin.
Let’s quickly go through the installation process of the Subscriptio—WooCommerce Subscriptions plugin once you’ve purchased and downloaded it from CodeCanyon. For this post, I’ve used the latest version of the Subscriptio—WooCommerce Subscriptions plugin: 2.4.9. I would recommend that you install it if you want to follow along with this post.
As soon as you purchase this plugin, you’ll be able to download the plugin zip file. It’s the WordPress plugin file which you could use to install this plugin from the WordPress admin side.
Go ahead and follow the standard WordPress plugin installation process and you’re almost done.
In this section, we’ll go through a couple of important back-end configuration settings. Head over to the WordPress admin side and access the Subscription > Settings section.
Under the General tab, it provides a couple of generic settings for the subscription cart. Among them, the settings under the Limits section are important. The Subscription limit setting allows you to configure subscriptions per customer. On the other hand, the Trial limit setting allows you to limit trails per customer.
In the Capabilities tab, you can enable or disable pausing and cancellation of subscriptions by customers.
Under the Flow tab, you can enable and configure period of renewal orders, payment reminders, overdue and suspensions. According to this, the email notifications will be sent.
So that was a brief about the important configuration settings. Next section on wards, we’ll go ahead and start working on subscriptions and related configuration.
Before we go ahead and start creating subscriptions let’s quickly go through what we’re going to achieve.
As discussed earlier, we’re going to sell magazine subscriptions, and we’ll create two types of subscriptions: half-yearly and yearly. If user buys a magazine without any subscription, it would cost 10$ per month. With half yearly subscription, the cost is 7$ per month with the subscription fee of 8$. On the other hand, it will take 5$ per month with the subscription fee of 20$ for yearly subscriptions.
In this section, we’ll see how to create subscription products. In fact, it’s pretty similar to what you’re used to with WooCommerce with the only difference is that you need to enter data related to the subscription if you want to make the product be subscription product.
Let’s go ahead and see how to create our first subscription product as shown in the following screenshot.

As you can see, you just need to select the Subscription checkbox if you want to make it a subscription product. When you check it, it displays a couple of extra fields related to subscription pricing. It’s important to understand these fields in the first place.
Firstly, we need to fill in the Regular price field for our product. As we’ve decided to charge 5$ per month for yearly subscription, you need to enter 5$ in that field.
The Price is per field is the frequency which will be used to regenerate new orders and charge customers. As we’re creating yearly subscription and want to charge every month, choose month in this field.
The Free trial field allows you to configure the trial period which you want to provide your customers. For example, if you enter 2 months in this field, customers won’t be charged for the first two months. In our case, we won’t give any free subscription, so you could leave it blank.
Next, the Sign-up fee field allows to configure a one time fee which you want to collect for the subscription. In our case, we will take 20$ signup fees for yearly subscription. Of course you could leave it blank, if you don’t want to charge it.
Finally, the max length field allows you to configure how long the subscription will run. In our case, we’ll select 12 months as we want to run it for a year.
Go ahead and enter the rest of the product details and save it. In the same way, go ahead and create half-yearly subscription product as shown in the following screenshot.

So we’ve created two subscription products, and we’ll see how it looks like on the front-end in the very next section.
In this section, we’ll see how subscription products look on the front-end.
Start by navigatng to the product detail page of the yearly subscription.

As you can see, the plugin clearly shows how much it’s going to cost you per month along with the sign-up fee. Let’s add this to cart and see how it looks like on the cart detail page.

So that’s what you pay: 25$. It includes the first month fees plus sign-up fees. And for the next 11 months, subscribers will have to pay 5$. And yes, they’re going to get automatic payment reminders before certain days as per your the configuration settings.
Go ahead and complete the order as usual, and we’ll see how subscriptions look like on the back-end in the next section.
As soon as the order is created which has subscription attached, you can view it on the back-end. Go ahead and navigate to the Subscriptions > Subscriptions section. This will list out all the subscriptions on your store.

The Status column indicates the status of the subscription order. Also, as depicted in the screenshot, you can see all the important information like start date of subscription, the next payment due date and subscription expiration date.
Also, this plugin takes care of sending automatic payment and subscription expiration reminders. If the subscriber doesn’t pay in time, it’ll suspend the subscription. And finally, it’ll cancel the subscription if there’s no action taken by subscribers.
So as you can see, this plugin provides a complete flow of subscription management which allows you to create different types of subscription products in your store and sell it easily.
And with that, we’ve reached the end of this tutorial as well.
Today, we discussed one of the most popular plugins in the WooCommerce category in WordPress: Subscriptio—WooCommerce Subscriptions. It’s a commercial plugin available at CodeCanyon at a very reasonable price.
Throughout this tutorial, we discussed the different aspects of this plugin along with the real-world example to demonstrate how it works. If you have any suggestions or comments, feel free to use the feed below and I’ll be happy to answer your queries!