(src/cart.php) Used to apply a frequency and frequency type to all items in the cart at the same time. The function takes two parameters: 

  • frequency integer (default: 1)
  • frequency type string (default: 'Months')


 * Applies a Schedule to the entire cart
 * @param int $frequency The Schedule Interval
 * @param string $frequency_type The Schedule Interval Type ( i.e. Months, Weeks, Days)
function autoship_set_full_cart_schedule( $frequency = 1, $frequency_type = 'Months' ){

  // Retrieve the cart contents
  $cart = WC()->cart->cart_contents;

  // Iterate through the cart and apply the schedule
  foreach( $cart as $cart_item_id => $cart_item ) {

    // Attach the Schedule
    $cart_item['autoship_frequency']      = $frequency;
    $cart_item['autoship_frequency_type'] = $frequency_type;

    // Update the Item in the cart
    WC()->cart->cart_contents[$cart_item_id] = $cart_item;


  // Update the Cart Session data.


Still need help? Contact Us Contact Us