autoship_get_product_default_relative_next_occurrence()

(src/products.php) Used to get the Next Occurrence Date for a product. It returns the Next Occurrence string or null if it doesn't exist. It takes the following parameters:

  • $product_id (integer)
  • $frequency_type (string)
  • $frequency (integer)

Function

/**
 * Gets the Autoship Relative Next Occurrence Date for a product.
 *
 * @param int $product_id. The WC Product or variation id.
 * @param string $frequency_type Optional. The Scheduled Frequency Type. Default Empty String
 * @param int $frequency Optional. The Scheduled Frequency. Default 0
 *
 * @return string|NULL The next occurrence string or NULL if doesn't exist.
 */
function autoship_get_product_default_relative_next_occurrence( $product_id, $frequency_type = '', $frequency = 0 ){

  $date = NULL;

  if ( 'yes' === autoship_relative_next_occurrence_enabled( $product_id ) ){

  // Get the Type and Value from the Parent Product
  $next_occurrence      = autoship_get_product_relative_next_occurrence(  $product_id );
  $next_occurrence_type = autoship_get_product_relative_next_occurrence_type(  $product_id );

  // Calculate the Relative Next Occurrence based on current date
  $date = autoship_calculate_relative_next_occurrence_date ( $next_occurrence, $next_occurrence_type,
  apply_filters( 'autoship_calculate_relative_next_occurrence_date_from_basedate', new DateTime() , $next_occurrence, $next_occurrence_type, $product_id, $frequency_type, $frequency ) );

  }

  return apply_filters( 'autoship_calculate_relative_next_occurrence_date', $date, $product_id, $frequency_type, $frequency );

}