autoship_get_full_cart_schedule()
(src/cart.php) Used to retrieve all schedules currently applied to the cart. The function takes no parameters and returns an array that includes each unique schedule frequency (integer) and autoship_frequency_type (string), the display_name (string), and the total number of cart items with that schedule.
Function
/** * Gets the current Schedules assigned to the cart * * @return array The current Schedules assigned to the cart. */ function autoship_get_full_cart_schedule(){ $schedule = array(); foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) { if ( isset( $values['autoship_frequency_type'] ) && !empty( $values['autoship_frequency_type'] ) && isset( $values['autoship_frequency'] ) && !empty( $values['autoship_frequency'] ) ){ // Attach Frequency & Frequency Type to cart items $schedule[$values['autoship_frequency_type'] .'-'. $values['autoship_frequency']] = array(); $schedule[$values['autoship_frequency_type'] .'-'. $values['autoship_frequency']]['frequency'] = $values['autoship_frequency']; $schedule[$values['autoship_frequency_type'] .'-'. $values['autoship_frequency']]['frequency_type'] = $values['autoship_frequency_type']; $schedule[$values['autoship_frequency_type'] .'-'. $values['autoship_frequency']]['display_name'] = autoship_get_frequency_display_name($values['autoship_frequency_type'], $values['autoship_frequency'] ); if ( !isset( $schedule[$values['autoship_frequency_type'] .'-'. $values['autoship_frequency']]['count'] ) ) $schedule[$values['autoship_frequency_type'] .'-'. $values['autoship_frequency']]['count'] = 0; $schedule[$values['autoship_frequency_type'] .'-'. $values['autoship_frequency']]['count']++; } } return $schedule; }