Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save niloyBrightVessel/5dcbeebed6e942df4f4cff92b53c91fe to your computer and use it in GitHub Desktop.
Save niloyBrightVessel/5dcbeebed6e942df4f4cff92b53c91fe to your computer and use it in GitHub Desktop.
Display a preorder date under cart item name in checkout
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