У вас есть 2 вопроса, один из которых касается активной подписки, которую вы можете протестировать с помощью этой функции:
function CheckSubscriptionByEmail($email) {
// getting all the records of the user by email for the subscription
$subscriptions = get_posts( array(
'numberposts' => -1,
'post_type' => 'ywsbs_subscription', // Subscription post type
'orderby' => 'post_date', // ordered by date
'order' => 'ASC',
'meta_query' => array(
array(
'key' => '_billing_email', //additional fields being used to get the data
'value' => $email,
'compare' => '='
),
array(
'key' => '_status',
'value' => 'active', //active subscriptions
'compare' => '='
))
) );
// check if user has any active subscription
foreach ( $subscriptions as $post ) : setup_postdata( $post );
$nextdue = get_post_meta(get_the_id(), '_payment_due_date',true);
$current_date = date("Y-m-d");
$date_to_compare = date("Y-m-d",strtotime($nextdue));
if (strtotime($date_to_compare) > strtotime($current_date)) {
echo "active"; //returns active
break;
}
endforeach;
wp_reset_postdata();
}
Ссылка и пояснения по адресу: https://makersbyte.com/check-active-subscriptions-using-yith-woocommerce/
Если вы хотите просто протестировать все активные подписки, измените в приведенной выше функции следующее:
$subscriptions = get_posts( array(
'numberposts' => -1,
'post_type' => 'ywsbs_subscription', // Subscription post type
'orderby' => 'post_date', // ordered by date
'order' => 'ASC',
'meta_query' => array(
array(
'key' => '_status',
'value' => 'active', //active subscriptions
'compare' => '='
))
) );
После того, как у вас есть список активных подписок, будет довольно просто отключить их, если это необходимо.
Платежный шлюз, просто перейдите в Woocommerce -> Checkout > В нем перечислены все платежные шлюзы. Используйте его для отключения.
person
Shahzaib Khan
schedule
22.09.2017