Last active
June 3, 2021 12:22
-
-
Save cubehrends/a0975bfd282fd825b908aea2f512befc to your computer and use it in GitHub Desktop.
Lieferzeit bei Lieferrückstand anpassen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_germanized_delivery_time_backorder_html', 'wdt_adjust_delivery_time_html', 10, 4 ); | |
function wdt_adjust_delivery_time_html( $text, $product ) { | |
// this must be a variation if we can find a parent_id | |
if ( $product->get_parent_id() ) { | |
$id = $product->get_parent_id(); | |
} else { | |
$id = $product->get_id(); | |
} | |
// let's try to find the parent delivery time in postmeta | |
if ( metadata_exists( 'post', $id, '_delivery_time_fallback' ) ) { | |
$delivery_times = get_terms( array( | |
'taxonomy' => 'product_delivery_time', | |
'hide_empty' => false, | |
) ); | |
$dtf_id = get_post_meta( $id, '_delivery_time_fallback', true ); | |
foreach ($delivery_times as $dtf) { | |
if ( $dtf->term_id == $dtf_id) { | |
$delivery_time = $dtf->name; | |
break; | |
} | |
} | |
} else { | |
$delivery_time = 'unknown'; | |
} | |
return 'Expected delivery '.$delivery_time; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment