autoship_create_scheduled_order_item_product_sale_price

(src > orders.php) Can be used to modify the regular sale price (recurring price) for a, order and takes the 1. Price, 2. Frequency, 3. Frequency Type, and 3. WC Product object as parameters.

Example

// change product price based on more frequent ordering
function xx_discount_based_on_frequency ($item_price, $frequency_type, $frequency,$product) {
    if($frequency_type == 'Weeks' && ($frequency == 1 || $frequency == 2)){
        $item_price = $item_price - ($item_price * .10);
    }
    if($frequency_type == 'Weeks' && $frequency == 3 ){
        $item_price = $item_price - ($item_price * .05);
    }
    return $item_price;
}
add_filter('autoship_create_scheduled_order_item_product_sale_price', 'xx_discount_based_on_frequency', 10, 4);

Still need help? Contact Us Contact Us