Skip to content

Instantly share code, notes, and snippets.

@jrick1229
Last active September 15, 2019 18:14
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jrick1229/6e4ad8deb0db4202f8f92dd88d33a767 to your computer and use it in GitHub Desktop.
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