I am trying to take this link below which is a search query and pull the item sku in woocommerce to be put in place of when they click the link. The code below is used to display a link in our store whenever an item is up for auction. How would I add $product->get_sku() in the middle of an href? I’ve tried multiple ways. Everything I find online about variable href only shows if the entire href is a variable. Any help is greatly appreciated.

https://www.wirebids.com/search?q=“VARIABLE HERE”&open_closed=open

    // Display Auction Link When 'auction' is in the category
if( has_term( 'auction', 'product_cat' ) ) {
    echo ' <style type="text/css">
                .woocommerce div.product form.cart, .woocommerce div.product p.cart {
                display:none ; }
                .woocommerce div.product p.price, .woocommerce div.product span.price {
                display:none ; }
                .woocommerce div.product p.stock {
                display:none ; }
                .product_meta {
                margin-top:20px;
                }
            </style>';
    echo 'Click This Button To View The Lot         ';
    echo '<a style="font-size:100%;color:#fff;padding:.618em 1em;border-radius:3px;background-color:#ed1c24;" href="https://www.wirebids.com/search?q="VARIABLE HERE"&open_closed=open" target="blank">' . __ ( 'On Auction Now!', 'your-plugin' ) . '</a>';
}'

Read more here: How do I add a variable in the middle of an href?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: