Last active
October 5, 2018 06:09
-
-
Save varun-pluginhive/f8b76ab1d1b1e07b6a7fe26d993f1e4c to your computer and use it in GitHub Desktop.
Snippet to display the Simple Date in Cart, Checkout and Thank you page and Date Range in Product Page. ESTIMATED DELIVERY DATE PLUGIN FOR WOOCOMMERCE - https://www.pluginhive.com/product/estimated-delivery-date-plugin-woocommerce/
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
/** | |
* Snippet to display the Simple Date in Cart, Checkout and Thankyou page and Date Range in Product Page. | |
* Created at : 05 Oct 2018 | |
* Updated at : 05 Oct 2018 | |
* PluginHive Plugins : https://www.pluginhive.com/plugins/ | |
* Gist Link : https://gist.github.com/varun-pluginhive/f8b76ab1d1b1e07b6a7fe26d993f1e4c | |
*/ | |
// Cart and Checkout Page | |
add_filter( 'xa_estimated_delivery_cart_checkout_page_html_formatted_date', function($html_date){ | |
$date_range_seperator = '-'; // Date Range Seperator | |
$date_to_display = 1; // O for Lower Range, 1 for Higher range | |
$cart_page_text = 'Estimated Delivery'; | |
$html_date_arr = explode( "</td></tr>", $html_date ); | |
if( ! empty($html_date_arr[0]) && ! empty($cart_page_text) ) { | |
$html_date_arr = array_map( 'trim', explode( $cart_page_text.'">', $html_date_arr[0]) ); | |
if( ! empty($html_date_arr[1]) ) { | |
$date_range = $html_date_arr[1]; | |
$date_arr = array_map( 'trim', explode( $date_range_seperator, $date_range ) ); | |
if( ! empty($date_arr[$date_to_display]) ) { | |
$html_date = str_replace( $date_range, $date_arr[$date_to_display], $html_date ); | |
} | |
} | |
} | |
return $html_date; | |
} ); | |
// Thankyou Page | |
add_filter( 'xa_estimated_delivery_thank_you_page_html_formatted_date', function($text){ | |
$date_range_seperator = '-'; // Date Range Seperator | |
$date_to_display = 1; // O for Lower Range, 1 for Higher range | |
$date_arr = array_map( 'trim', explode( $date_range_seperator, $text) ); | |
! empty($date_arr[$date_to_display]) && $text = $date_arr[$date_to_display]; | |
return $text; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment