Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
For use with fixed expiration date subscriptions (not End Date). Typically only possible while using an AutomateWoo workflow. This will add a new line in the cart if the $product_id is present, displaying when the subscription will expire.
<?php
function wcs_add_cart_first_renewal_payment_date_EXP( $order_total_html, $cart ) {
$product_id = '19';
$product_cart_id = WC()->cart->generate_cart_id( $product_id );
$in_cart = WC()->cart->find_product_in_cart( $product_cart_id );
$title_exp = get_the_title( $product_id );
if ( 0 !== $cart->next_payment_date ) {
if ( $in_cart ) {
$expiration_date = 'December 31, 2019';
// translators: placeholder is a date
$order_total_html .= '<div class="first-expiration-date"><small>' . sprintf( __( '<br><hr>Subscription containing <strong>%s</strong> will expire on: %s', 'woocommerce-subscriptions' ), $title_exp, $expiration_date ) . '</small></div>';
}
}
return $order_total_html;
}
add_filter( 'wcs_cart_totals_order_total_html', 'wcs_add_cart_first_renewal_payment_date_EXP', 99, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.