autoship_maybe_update_cart_item_relative_next_occurrence()
(src/products.php) Used to check if a Next Occurrence date of a product in the cart should be recalculated. It returns the recalculated date and takes the following parameters:
- $product_id (integer)
- $next_occurrence (string)
- $frequency_type (string)
- $frequency (integer)
Function
/**
* Checks if a Next Occurrence should be updated.
*
* @param int $product_id. The WC Product or variation id.
* @param string $next_occurrence The next occurrence string.
* @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_maybe_update_cart_item_relative_next_occurrence( $product_id, $next_occurrence, $frequency_type = '', $frequency = 0 ){
$date = $next_occurrence;
// Re-Calculate the Relative Next Occurrence for the cart item if it's stale.
if ( apply_filters('autoship_cart_item_relative_next_occurrence_is_stale', true, $product_id, $next_occurrence ) )
$date = autoship_get_product_default_relative_next_occurrence( $product_id, $frequency_type, $frequency );
return apply_filters( 'autoship_maybe_update_item_relative_next_occurrence_date', $date, $product_id, $next_occurrence, $frequency_type, $frequency );
}