Append Woocommerce product name to end of URL

[ad_1]

I have a custom button on my WooCommerce product pages that redirects to another website where the products can actually be bought (not WooCommerce). I would like for the link to add the title of the product at the end of the url, after the backslash. It would be something like: shopsite.com/name-of-product where the shopsite.com part is always the same, and through PHP or something else, the name-of-product just copies the product’s title and adds it to the end.

Right now, I have this:

function my_extra_button_on_product_page() {
global $product;
echo ‘<a id=”submit” class=”submit” href=”https://www.shop.bessia.com.ar/<?= get_title ?>”>Comprar en Mercado Shops</a>’;
}

Thanks!

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer