How to get WooCommerce Pages URL programmatically


 

Are you trying to figure out how to obtain the WooCommerce Pages URL? Do you want to make a change? You’ve arrived at the right location. We’ll teach you how to access the WooCommerce Shop URL programmatically and how to modify it to get the most out of it in this post.

The Default WooCommerce Shop Page URL

The default shop page on a WooCommerce online store is the website URL with a slash and the string “shop,” as you may know. For instance, https://nextwoo.themedev.net/shop That’s why, in most circumstances, determining the shop URL of an eCommerce store created with WooCommerce is simple.

In the backend, go to WooCommerce > Settings > Products in your dashboard to locate the shop URL.

The Advanced tab is also where you’ll discover the remainder of WooCommerce’s pages, such as cart, checkout, my account, and terms & conditions.

As you can see, all you have to do to find your WooCommerce store’s shop URL is go to the settings page in the admin dashboard. But what if you need to get the URL in order to create a link or do some type of code validation?

We’ll show you how to access the shop URL programmatically in the next part, as well as some other helpful hints.

How to Get the WooCommerce shop URL?

First, let’s see how to get the shop URL in WooCommerce. With the following snippet, you’ll get the base shop for your website:

    $shop_page_url = get_permalink( wc_get_page_id( 'shop' ) );

To print the URL on the front end, you can use a hook. If you’re not familiar with hooks, we highly recommend you have a look at this guide.

In this example, we’ll use the wp_header hook so the URL will be printed above the header.

add_action('wp_head',function(){
    $shop_page_url = get_permalink( wc_get_page_id( 'shop' ) );
    echo $shop_page_url;
}

Now that you got your shop URL, let’s see different examples to customize it.

NOTE: To test all of the following scripts, we recommend using the obtain shop URL sample script.

How to change the WooCommerce Shop URL?

We’ll show you how to update the base shop URL in WooCommerce in this section. To do so, you’ll need to start by creating a new page on which the shop will be printed.

Go to Pages > Add New in your WooCommerce dashboard, create an empty page, and give it a name. After that, go to the WooCommerce Settings page and select your newly created page from the Shop Page menu. We’ve established a new page called Store in this example.

That concludes our discussion. Your Shop page will be the new page you built from now on. This new base store URL will print all of the products in the same way that the default shop page does.

Similarly, the Advanced tab allows you to edit the cart, checkout, My Account, and Terms & Conditions pages.

How customize WooCommerce Pages by Plugin?

NextWoo provides the services to build WooCommerce templates with its editor flexibility for Elementor & Gutenberg. Multi-designed WooCommerce single product layout builder – NextWoo

NextWoo is a WooCommerce Builder to build a Single Product, Cart, Checkout, My Account, Shop Loop, related products, Quick view, Up-sell, Cross sale, and so on by Elementor or Gutenberg.

Elementor is a popular WordPress page builder plugin. It lets you easily create custom layouts for your WordPress pages with a drag & drop interface.

Extraordinary Features of NextWoo:

1.  Create unlimited templates for woo customization

You can create unlimited templates for Single Products, Shop layout, Archive Layout, Checkout, My Account, Cart, Related products, and more WooCommerce pages.

2.  Set preset woo templates by onclick

With a single click, you can set Woo layout templates from pre-build designs. It will surely save you time.

3.  Build templates with Elementor & Gutenberg

NextWoo offers Elementor & Gutenberg to build or customize beautiful woo templates, there are 100+ Widgets and Blocks are available for both Elementor & Gutenberg editors.                       

4.  Supports multiple product type

Easily build variable, grouped, subscription, and simple products layout using Elementor | Gutenberg Widgets.

5.  Construct versatile shop page templates

Use the Shop widgets to craft a decent template that presents all products in the best light. Get extra features:  AJAX add to cart method, Quick View, Compare Button, Wishlist, Image Slider, and so no

6.  Custom Checkout page template

Form a beautiful checkout page that is fully covered with order review, billing, shipping, and payments information.

7.  Built with Success template

Build and apply a Thank You page to complete the purchasing process that contains the following formalities like order details, order, Customer Address Details, and more.

8.  Customize quick view template

Create a customizable Quick View page to see the short information of products.

How to get WooCommerce pages URL?

We just learned how to retrieve the WooCommerce shop URL and alter it. Let’s look at how to acquire the URLs of other pages programmatically so you can use them in your scripts.

More details

Comments

Popular posts from this blog

How to Fix Elementor Not Loading Error Step by Step?

The Importance of Using Pill Box for Medication Management