我試圖採取下面這個鏈接,這是一個搜索查詢,並將woocommerce中的項目sku代替他們點擊鏈接的位置。下面的代碼用於顯示我們商店中每次拍賣物品時的鏈接。我如何在href中添加$ product-> get_sku()?我嘗試了多種方式。我在網上找到的關於變量href的所有內容只顯示整個href是否爲變量。任何幫助是極大的讚賞。如何在href中添加變量?
https://www.wirebids.com/search?q= 「變量HERE」 & open_closed =開放
// Display Auction Link When 'auction' is in the category
function so_43372512_maybe_show_auction_link(){
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 ';
$skusearch = $product-get_sku();
echo '<a id="auction" style="font-size:100%;color:#fff;padding:.618em 1em;border-radius:3px;background-color:#ed1c24;font-weight:700;" href="https://www.wirebids.com/search?q=' . $skusearch . '&open_closed=open" target="blank">' . __ ('On Auction Now!', 'your-plugin') . '</a>';
}
}'
我更新了我的代碼來告訴你我有事情。添加我擁有它的變量會破壞函數。現在感覺很笨拙哈哈。
真棒,我終於沒有得到破頁。但我需要使用$ product-> get_sku(),並且當我添加get sku部分時,它會中斷鏈接。我可以定義一個變量來獲取sku並在那裏使用它嗎? – hippocoder
你去了嗎,那好吧 – RiggsFolly
好吧,這聽起來真的很愚蠢,但我應該把\t $ VARIABLENAME = $ product-> get_sku();在我的功能?當我在href上面添加它時,它會再次破壞頁面。 – hippocoder