Skip to content

Instantly share code, notes, and snippets.

@renjith-ph
Last active January 10, 2019 14:11
Show Gist options
  • Select an option

  • Save renjith-ph/f09a0d45a5f23f13a575e8f80275ab38 to your computer and use it in GitHub Desktop.

Select an option

Save renjith-ph/f09a0d45a5f23f13a575e8f80275ab38 to your computer and use it in GitHub Desktop.
Add backorder product message above the estimated delivery text
add_filter( 'xa_estimated_delivery_cart_checkout_page_html_formatted_date', 'ph_estimated_delivery_modify_cart_checkout_page_html',11,2 );
function ph_estimated_delivery_modify_cart_checkout_page_html( $text, $test ) {
global $woocommerce;
$items = $woocommerce->cart->get_cart();
$count=0;
foreach($items as $item => $values) {
$product_id=(wp_get_post_parent_id($values['data']->get_id())==0) ? $values['data']->get_id() : wp_get_post_parent_id($values['data']->get_id());
if($values['data']->get_stock_status()=='onbackorder')
{
$count++;
break;
}
}
if($count > 0)
{
$back_order_text='<tr class="shipping"><th>Your cart having back-order products</th></tr>'; // add your message here
$text=$back_order_text.$text;
}
return $text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment