wc_autoship_cart_item_discount (filter)

Alter the discount applied to an item in an Autoship order.

Example

<?php
/**
* @param float $discount
* @param string $cart_item_key
* @param string $price_product_id
* @param int $autoship_frequency
* @param int $current_user_id
* @return float 
*/
function wc_autoship_cart_item_discount_example($discount, $cart_item_key, $price_product_id, $autoship_frequency, $current_user_id ) {
  // Institute a $1 discount on items with a frequency of less than a week
  if ( $autoship_frequency < 7 ) {
    $discount = 1.00;
  }
  return $discount;
}
add_filter( 'wc_autoship_cart_item_discount', 'wc_autoship_cart_item_discount_example', 10, 5 );

Still need help? Contact Us Contact Us