mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-03 12:12:25 +08:00
https://stackoverflow.com/questions/76759540/include-a-product-attribute-to-the-displayed-price-for-out-of-stock-products-in
10 lines
430 B
Text
10 lines
430 B
Text
add_filter( 'woocommerce_get_price_html', 'custom_displayed_out_of_stock', 10, 2 );
|
|
function modify_price_out_of_stock_items( $price_html, $product ) {
|
|
if ( ! is_admin() && ! $product->is_in_stock() ) {
|
|
return sprintf( __('Last ticketed at %s in %s', 'woocommerce'),
|
|
wc_price( wc_get_price_to_display( $product ) ),
|
|
$product->get_attribute('Year')
|
|
);
|
|
}
|
|
return $price_html;
|
|
}
|