Created
February 1, 2021 11:17
-
-
Save niloyBrightVessel/5dcbeebed6e942df4f4cff92b53c91fe to your computer and use it in GitHub Desktop.
Display a preorder date under cart item name in checkout
This file contains hidden or 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
add_filter('woocommerce_cart_item_name', 'bpPreorderDateInCheckoutItems',10,3); | |
// Display a preorder date under cart item name in checkout | |
function bpPreorderDateInCheckoutItems($p_name,$cart_item, $cart_item_key) | |
{ | |
// Here below define your shipping class slug | |
$isPreoder = get_post_meta($cart_item['product_id'], '_is_pre_order', true); | |
$PreOrderDate = get_post_meta($cart_item['product_id'], '_pre_order_date', true); | |
if ('yes' == $isPreoder && strtotime($PreOrderDate) > time()) { | |
$timeFormat = date_i18n(get_option('date_format'), strtotime($PreOrderDate)) ; | |
$humanTime = human_time_diff(time(), strtotime($PreOrderDate)); | |
$text = sprintf(get_option('wc_preorders_avaiable_date_text'), $timeFormat, $humanTime, $timeFormat) ; | |
$p_name .= '<br />'.apply_filters('preorder_avaiable_date_text', $text); | |
} | |
return $p_name; | |
} | |
add_filter('preorder_cart_item_att', 'bvWrapperItem'); | |
function bvWrapperItem($attr) | |
{ | |
$attr = 'style="color:#ac162c"'; | |
return $attr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment