:::: MENU ::::
Browsing posts in: WordPress

WooCommerce get Product URL

Today we talk about WooCommerce or WordPress get product URL. In this tutorial, We focus on getting the product URL by product id. You can use the get_permalink function to get the product URL. You need to pass the product id to get the URL.

Let’s start with our example.

$productId      = 1; // product id
$productUrl = get_permalink($productId)
Author: Qaisar Satti
Last Modified: March 26, 2021


WordPress get page URL

Today we talk about WooCommerce or WordPress get page URL. In this tutorial, We focus on getting the page URL by page id. You can use the get_permalink function to get the product URL. You need to pass the page id to get the URL.

Let’s start with our example.

$pageId      = 1; // page id
$pageUrl = get_permalink($pageId)
Author: Qaisar Satti
Last Modified: March 26, 2021


WooCommerce get current user role

Today we talk about WooCommerce or WordPress get the current user role. In this tutorial, We focus on getting the current user group for example you need to match or check what is current user role. On the basis of that need to give a discount or show some extra text.

Let’s start with our example.

// get Current User Role
$currentUser      = wp_get_current_user();
$currentUserRole = $currentUser->roles[0];
Author: Qaisar Satti
Last Modified: February 23, 2021


WooCommerce get previous URL

Today we talk about WooCommerce or WordPress get the previous URL or referrer URL. In this tutorial, We focus on getting the previous URL for example you need to match or check what was the previous URL. Sometimes you need to perform the action according to the user’s previous page.

Let’s start with our example.

$previousUrl = esc_url(wp_get_referer());
Author: Qaisar Satti
Last Modified: February 23, 2021


WooCommerce get current url

Today we talk about WooCommerce or WordPress get the current URL. In this tutorial, We focus on getting the current URL for example you need to match or check what is current URL of the category Url or product URL or any other page URL.

Let’s start with our example.

$currentUrl = home_url($_SERVER['REQUEST_URI']);
Author: Qaisar Satti
Last Modified: June 2, 2021


Pages:123