0

Using the call back hook, I can get the subscription information of everything EXCEPT the expiration date. Any thoughts on how to grab this. This is what I have:

function mmd_woointerface_ProcessOrder($order_id) 
{
$order           = new WC_Order( $order_id );                  
$OrderNumber     = $order->parent_id;
$ParentOrder     = new WC_Order( $OrderNumber );
$TransactionId   = $ParentOrder->get_transaction_id();

$DatePaid                   = $order->date_created;
$SubscriptionNumber         = $order->get_order_number();
$PaymentDate                = $order->get_date_created()->format ('Y-m-d');
$ProductId                  = $product->get_product_id();  
$subscriptions              = wcs_get_users_subscriptions( $UserId );
foreach ($subscriptions as $sub)
  {
  if($sub->ID == $SubscriptionNumber)                              
  $ExpireDate = $sub->get_expiration_date( 'next_payment' ); <<NOT ACCURATE
  $ExpireDate = WC_Subscriptions_Order::get_next_payment_date ( $ParentOrder, $ProductId  );   << SAME PROBLEM
  }
 }

These calls:

 $ExpireDate = $sub->get_expiration_date( 'next_payment' ); 

 $ExpireDate = WC_Subscriptions_Order::get_next_payment_date ( $ParentOrder, $ProductId  ); 

are not effective when you have a user who makes a manual early payment. It just returns the next payment date, verses the actual stored expiration date

0

Based on the documentation (product, subscription) I would assume that either

WC_Subscriptions_Product::get_expiration_date( $ProductId );

or

WC_Subscription::get_date( 'end' );

should return the expiration date.

  • That does not work and have done that, since it is the product line and just does a calculation based on today's date. 'end' is used when a subscription type has a end, these subscriptions never "end", they just renew. But somewhere the new date is stored. – Debbie Kurth Mar 25 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.