我正在使用条纹" wc_gateway_stripe_process_response"来获取付款信息。需要的是该产品的付款间隔以及用户的订阅ID是什么。这是我约会的代码:
function woointerface_ProcessOrder($order_id)
{
$order = new WC_Order( $order_id );
$TransactionId = $order->get_transaction_id();
$szOrderId = $order->get_order_number();
// Find all products associated with this order
$order_data = $order->get_data();
$order_billing_email = $order->get_billing_email();
$payment_method = $order->get_payment_method_title();
$PaymentDate = $order->get_date_paid();
$OrderNumber = $order->get_order_number();
$User = get_user_by( 'email', $order_billing_email );
$FirstName = $User->first_name;
$LastName = $User->last_name;
$UserId = $User->ID;
$PayerName = $FirstName . ' ' . $LastName;
$items = $order->get_items();
foreach( $items as $item_id => $product )
{
$ProductName = $product->get_name();
$ProductId = $product->get_product_id();
$PaymentAmount = $product->get_total();
$ProductIndex = wc_get_product($ProductId);
if(! WC_Subscriptions_Product::is_subscription( $ProductIndex ) )
continue;
$UserSubscriptionId = ??
$BillingCycle = ??
// Store in local table.
}
寻找如何获取此订单的用户订阅ID和计费周期。
找到了计费和ID的解决方案。以下电话为您提供帐单和用户订阅ID信息:
$BillingCycle = WC_Subscriptions_Product::get_interval($ProductIndex); // how many times within the period to bill
$BillingPeriod = WC_Subscriptions_Product::get_period($ProductIndex); // Month/week/Year
$subscriptions = wcs_get_subscriptions(array('order_id' => $order->id, 'product_id' => $ProductId));
if (!empty($subscriptions))
{
$subscription = array_pop($subscriptions);
$PaidSubscriptionId = $subscription->id;
}