Я продаю планы технического обслуживания и защиты через наш веб -сайт, используя гравитационные формы и полосы. У меня есть 3 планы настройки с 3 различными «каналами» полосы, и я настроил этот пользовательский фрагмент, чтобы заставить дату выставления счетов привязки приспособиться к 1 -м, но пока он не работает.
if ( defined( 'WP_DEBUG' ) ) {
error_log( 'WP_DEBUG is defined and set to: ' . ( WP_DEBUG ? 'true' : 'false' ) );
} else {
error_log( 'WP_DEBUG is NOT defined.' );
}
if ( defined( 'WP_DEBUG_LOG' ) ) {
error_log( 'WP_DEBUG_LOG is defined and set to: ' . ( WP_DEBUG_LOG ? 'true' : 'false' ) );
} else {
error_log( 'WP_DEBUG_LOG is NOT defined.' );
}
error_log( 'PHP error_log path (ini_get): ' . ini_get( 'error_log' ) );
error_log( 'PHP display_errors (ini_get): ' . ini_get( 'display_errors' ) );
// // Add this to your theme's functions.php or a custom plugin
add_filter( 'gform_stripe_subscription_params_pre_update_customer', 'gf_stripe_set_billing_anchor_to_first_of_month', 10, 3 );
function gf_stripe_set_billing_anchor_to_first_of_month( $params, $form, $entry ) {
error_log( 'GF Stripe Billing Anchor: Function started for entry ID: ' . rgar( $entry, 'id' ) );
error_log( 'GF Stripe Billing Anchor: Current feed ID being processed: ' . $params['feed_id'] );
$target_feed_ids = array( 5, 4, 3 ); // Example: Change this to your actual Stripe Feed IDs
error_log( 'GF Stripe Billing Anchor: Configured target feed IDs: ' . implode( ', ', $target_feed_ids ) );
// Check if this is one of the correct Stripe Feeds
if ( ! in_array( $params['feed_id'], $target_feed_ids ) ) {
error_log( 'GF Stripe Billing Anchor: Current feed ID ' . $params['feed_id'] . ' is NOT in the target list. Exiting.' );
return $params;
}
error_log( 'GF Stripe Billing Anchor: Current feed ID ' . $params['feed_id'] . ' IS in the target list. Proceeding.' );
// Calculate the 1st of the next month as a Unix timestamp
$current_day = date( 'j' ); // Get current day of the month
error_log( 'GF Stripe Billing Anchor: Current day of month: ' . $current_day );
if ( $current_day == 1 ) {
// If today is the 1st, set the anchor to the 1st of the current month
$billing_anchor_date = strtotime( date( 'Y-m-01' ) );
error_log( 'GF Stripe Billing Anchor: Today is the 1st. Anchor set to start of current month.' );
} else {
// Otherwise, set the anchor to the 1st of the next month
$billing_anchor_date = strtotime( 'first day of next month' );
error_log( 'GF Stripe Billing Anchor: Today is NOT the 1st. Anchor set to first day of next month.' );
}
error_log( 'GF Stripe Billing Anchor: Calculated billing_cycle_anchor (timestamp): ' . $billing_anchor_date );
error_log( 'GF Stripe Billing Anchor: Calculated billing_cycle_anchor (date): ' . date( 'Y-m-d H:i:s', $billing_anchor_date ) );
// Set the billing_cycle_anchor parameter
$params['billing_cycle_anchor'] = $billing_anchor_date;
// Optional: Handle proration behavior
// By default, Stripe will prorate the first invoice from the signup date to the billing_cycle_anchor.
// If you want the first period to be free until the 1st of the month, uncomment the line below.
// $params['proration_behavior'] = 'none';
// error_log( 'GF Stripe Billing Anchor: Proration behavior: ' . ( isset( $params['proration_behavior'] ) ? $params['proration_behavior'] : 'default' ) );
error_log( 'GF Stripe Billing Anchor: Function finished. Returning parameters.' );
return $params;
}
< /code>
Может ли кто -нибудь определить, где я ошибаюсь? Я использую плагин на пользовательские фрагменты для вставки кода в сайт точно так же, как это было вставлено здесь.
Подробнее здесь: https://stackoverflow.com/questions/797 ... ms-snippet
Установите якорь счетов на 1 -е место в полосе, используя гравитационные формы. ⇐ Php
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Установите якорь счетов на 1 -е место в полосе, используя гравитационные формы.
Anonymous » » в форуме Php - 0 Ответы
- 52 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Позиция-якорь не работает, когда якорь находится в положении: исправлено
Anonymous » » в форуме Html - 0 Ответы
- 37 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Позиция-якорь не работает, когда якорь находится в положении: исправлено
Anonymous » » в форуме Html - 0 Ответы
- 34 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Позиция-якорь не работает, когда якорь находится в положении: исправлено
Anonymous » » в форуме Html - 0 Ответы
- 34 Просмотры
-
Последнее сообщение Anonymous
-