Skip to content

Instantly share code, notes, and snippets.

@remcotolsma
Created August 6, 2021 13:40
Show Gist options
  • Save remcotolsma/d16112c744c1f43c0e979cbec8eef9e0 to your computer and use it in GitHub Desktop.
Save remcotolsma/d16112c744c1f43c0e979cbec8eef9e0 to your computer and use it in GitHub Desktop.
Display Pronamic Pay subscriptions that require follow-up payment
<?php
define( 'WP_USE_THEMES', false );
require '../wp-blog-header.php';
$args = array(
'post_type' => 'pronamic_pay_subscr',
'nopaging' => true,
'orderby' => 'post_date',
'order' => 'ASC',
'post_status' => array(
'subscr_pending',
'subscr_failed',
'subscr_active',
),
'meta_query' => array(
array(
'key' => '_pronamic_subscription_source',
'compare' => 'NOT IN',
'value' => array(
// Don't create payments for sources which schedule payments.
'woocommerce',
),
),
),
);
$args['nopaging'] = true;
$args['meta_query'][] = array(
'relation' => 'OR',
array(
'key' => '_pronamic_subscription_next_payment',
'compare' => '<=',
'value' => current_time( 'mysql', true ),
'type' => 'DATETIME',
),
array(
'key' => '_pronamic_subscription_next_payment_delivery_date',
'compare' => '<=',
'value' => current_time( 'mysql', true ),
'type' => 'DATETIME',
),
);
$query = new WP_Query( $args );
echo '<ul>';
foreach ( $query->posts as $post ) {
echo '<li>';
printf(
'<a href="%s">Processing post `%d` - "%s"…</a>',
\get_edit_post_link( $post ),
$post->ID,
get_the_title( $post )
);
$subscription = \get_pronamic_subscription( $post->ID );
$date = \get_post_meta( $post->ID, '_pronamic_subscription_next_payment_delivery_date', true );
echo ' <code>', $date, '</code>';
echo '</li>';
}
echo '</ul>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment