Skip to content

Instantly share code, notes, and snippets.

@mmilosheski
Created July 22, 2021 07:17
Show Gist options
  • Save mmilosheski/942c960b9f8d3c08264d3c082bfd1686 to your computer and use it in GitHub Desktop.
Save mmilosheski/942c960b9f8d3c08264d3c082bfd1686 to your computer and use it in GitHub Desktop.
Adding Custom Delivery Date Message to Cart Totals (Checkout + Cart Pages / Woo)
<?php
add_action( 'woocommerce_cart_totals_after_shipping', 'add_delivery_date_message', 20 );
add_action( 'woocommerce_review_order_after_shipping', 'add_delivery_date_message', 20 );
function add_delivery_date_message() {
// Loop through cart items and calculate total volume
foreach( WC()->cart->get_cart() as $cart_item ){
// if you need cart items for some calculations
}
// The Output
echo ' <tr class="cart-delivery-date-message">
<th>' . __( "Delivery Date", "woocommerce" ) . '</th>
<td data-title="delivery-date">Estimated DD/MM/YY - DD/MM/YY</td>
<td data-title="delivery-warehouse"><small>Ships from {$warehouse_location} warehouse</small></td>
<td data-title="delivery-date"><small>Including the {$item_name} is delaying this order</small></td>
<td data-title="delivery-date"><small style="color: red;">Estimated delivery valid until {$time} today</small></td>
</tr>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment