autoship_get_product_prices
(src > product-options.php) Takes the WC product id and returns an array of prices and discount percentages for that product id. The included prices are the following:
1. Autoship Checkout Price
2. Autoship Recurring Price
3. Regular Price
4. Sale Price
5. Percent Discount
6. Percent Recurring Discount
Example
// Adjust Scheduled Order Checkout Price. function xx_adjust_checkout_price( $checkout_price, $product_id, $frequency_type, $frequency ){ // Adjust the checkout price based on the frequency and type if ( ( 'Days' == $frequency_type ) && ( 1 == $frequency ) ){ $discount_pct = .5; } else if ( ( 'Weeks' == $frequency_type ) && ( 1 == $frequency ) ){ $discount_pct = .25; } else if ( ( 'Months' == $frequency_type ) && ( 1 == $frequency ) ){ $discount_pct = .10; } return $checkout_price - round( $checkout_price * $discount_pct , 2 ); } add_filter( 'autoship_checkout_price', 'xx_adjust_checkout_price', 10, 4 ); // Adjust Scheduled Order Recurring Price. function xx_adjust_recurring_price( $scheduled_order_item_data, $frequency_type, $frequency ) { // Adjust the recurring price based on the frequency and type if ( ( 'Days' == $frequency_type ) && ( 1 == $frequency ) ){ $discount_pct = .5; } else if ( ( 'Weeks' == $frequency_type ) && ( 1 == $frequency ) ){ $discount_pct = .25; } else if ( ( 'Months' == $frequency_type ) && ( 1 == $frequency ) ){ $discount_pct = .10; } $scheduled_order_item_data["SalePrice"] = $scheduled_order_item_data["Price"] - round( $scheduled_order_item_data["Price"] * $discount_pct , 2 ); return $scheduled_order_item_data; } add_filter( 'autoship_get_scheduled_order_item_product_data', 'xx_adjust_recurring_price', 11, 3 );