Skip to content

Instantly share code, notes, and snippets.

@kreamweb
Created February 23, 2017 09:59
Show Gist options
  • Select an option

  • Save kreamweb/51e3951c2703742500072252348a066b to your computer and use it in GitHub Desktop.

Select an option

Save kreamweb/51e3951c2703742500072252348a066b to your computer and use it in GitHub Desktop.
add a message to customer with the date of next payment
<?php
if ( defined( 'YITH_YWSBS_PREMIUM' ) ) {
add_action( 'woocommerce_init', 'ywsbs_add_notice' );
function ywsbs_add_notice(){
if( is_user_logged_in()){
$current_user = wp_get_current_user();
$sbs = YITH_WC_Subscription()->get_user_subscriptions( $current_user->get('ID'), $status = 'active' );
foreach ( $sbs as $sub_id ){
$subscription = ywsbs_get_subscription( $sub_id );
if( ! empty( $subscription->payment_due_date ) ){
//expired_date - payment_due_date
wc_add_notice( sprintf( 'Your subscription will expire on %s.', date_i18n( wc_date_format(), $subscription->payment_due_date ) ), 'notice' );
}elseif ( ! empty( $subscription->expired_date) ){
wc_add_notice( sprintf( 'Your subscription will expire on %s.', date_i18n( wc_date_format(), $subscription->expired_date ) ), 'notice' );
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment