wc_autoship_cart_item_price (filter)

Alter the price of an Autoship item at checkout.

Example

<?php
/**
* @param float $price
* @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_price_example( $price, $cart_item_key, $price_product_id, $autoship_frequency, $current_user_id ) {
  // Institute a 10% discount on items with a frequency of less than a week
  if ( $autoship_frequency < 7 ) {
    $price *= 0.10;
  }
  return $price;
}
add_filter( 'wc_autoship_cart_item_price', 'wc_autoship_cart_item_price_example', 10, 5 );

Still need help? Contact Us Contact Us