admin管理员组文章数量:1327524
Hello i have problem with my woocommerce downloads section in "my account" page - span tags between product name and variation name.
.png
I tried to make a snippet:
add_filter( 'woocommerce_customer_available_downloads', 'remove_span_dl_name', 10, 7);
function remove_span_dl_name( $download ){
return str_replace( '<span> - </span>', ' - ',$download['download_name']);
}
but it removes all downloads altogether.
And this one do nothing:
add_filter( 'woocommerce_available_download_link', 'remove_span_dl_name', 10, 7);
function remove_span_dl_name( $download ){
return str_replace( '<span> - </span>', ' - ',$download['download_name'] );
}
What is my mistake and how can I get rid of these tags?
Hello i have problem with my woocommerce downloads section in "my account" page - span tags between product name and variation name.
https://i.sstatic/TIg0X.png
I tried to make a snippet:
add_filter( 'woocommerce_customer_available_downloads', 'remove_span_dl_name', 10, 7);
function remove_span_dl_name( $download ){
return str_replace( '<span> - </span>', ' - ',$download['download_name']);
}
but it removes all downloads altogether.
And this one do nothing:
add_filter( 'woocommerce_available_download_link', 'remove_span_dl_name', 10, 7);
function remove_span_dl_name( $download ){
return str_replace( '<span> - </span>', ' - ',$download['download_name'] );
}
What is my mistake and how can I get rid of these tags?
Share Improve this question edited Aug 18, 2020 at 23:39 Nate Allen 2,1062 gold badges16 silver badges23 bronze badges asked Aug 9, 2020 at 23:14 Kuroi RyuuKuroi Ryuu 12 bronze badges1 Answer
Reset to default 0Remember that str_replace
looks for an exact match of the 'needle' (what you are searching for; 'haystack' is the thing you are searching inside). So your code is not finding an exact match.
If you want to do a 'replace everything that might be within the span codes in that hunk of text', then a regex statement might be in order. This is assuming that the 'haystack' you are searching is different each time. (Since I don't read your language, can't tell for sure.
But, assuming that $download['donload_name']
contains the start and stop span tag, and something in the middle, then try to do two str_replace commands: one for the <span>
and one for </span>
.
And that assumes that there aren't any parameters to the <span>
. If there are, a regex might be better idea.
本文标签: phpRemove span tags from WooCommerce Downloads page
版权声明:本文标题:php - Remove span tags from WooCommerce Downloads page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742178559a2428034.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论