autoship_get_product_prices (function)
(src/products.php) Takes the (WooCommerce) $product_id as its parameter and returns an array of prices and discount percentages for that product id which can be modified using the included autoship_all_prices_array filter
Function
/**
* Retrieves all of a products prices with and without tax ( Autoship & WC ).
* NOTE: This value can be modified via the autoship_all_prices_array filter.
*
* @param int $product_id. The product or variation id.
* @return array The Autoship and WC prices
*/
function autoship_get_product_prices( $product_id ){
// Get the Product
$product = wc_get_product( $product_id );
$prices = array();
// The Products Current Price.
$prices['price'] = $product->get_price();
// The Products Current Price including or excluding tax, based on the 'woocommerce_tax_display_shop' setting.
$prices['display_price'] = wc_get_price_to_display( $product, array( 'price' => $prices['price'] ) );
// The Products Regular Price if/when it's not on sale.
$prices['regular_price'] = $product->get_regular_price();
// The Products Regular Price if/when it's not on sale including or excluding tax, based on the 'woocommerce_tax_display_shop' setting.
$prices['regular_display_price'] = wc_get_price_to_display( $product, array( 'price' => $prices['regular_price'] ) );
// The Products Sale Price
$prices['sale_price'] = $product->get_sale_price();
// The Products Regular Price if/when it's not on sale including or excluding tax, based on the 'woocommerce_tax_display_shop' setting.
$prices['sale_display_price'] = wc_get_price_to_display( $product, array( 'price' => $prices['sale_price'] ) );
// The Custom Autoship Checkout Price
$prices['autoship_checkout_price'] = autoship_get_product_checkout_price( $product_id );
// The Custom Autoship Checkout Price including or excluding tax, based on the 'woocommerce_tax_display_shop' setting.
$prices['autoship_checkout_display_price'] = wc_get_price_to_display( $product, array( 'price' => $prices['autoship_checkout_price'] ) );
// The final Checkout Price ( either Autoship or WC )
$prices['checkout_price'] = autoship_checkout_price( $product, array( 'price' => $prices['price'], 'discount' => $prices['autoship_checkout_price'] ) );
// Record if the price is WC or Autoship
$prices['checkout_price_is_autoship'] = $prices['checkout_price'] != $prices['price'];
// The final Checkout Price ( either Autoship or WC ) including or excluding tax, based on the 'woocommerce_tax_display_shop' setting.
$prices['checkout_display_price'] = wc_get_price_to_display( $product, array( 'price' => $prices['checkout_price'] ) );
// The Custom Autoship Price for Recurring Orders
$prices['autoship_recurring_price'] = autoship_get_product_recurring_price( $product_id );
// The Custom Autoship Price for Recurring Orders including or excluding tax, based on the 'woocommerce_tax_display_shop' setting.
$prices['autoship_recurring_display_price'] = wc_get_price_to_display( $product, array( 'price' => $prices['autoship_recurring_price'] ) );
// Get the calculated Percent Discount for the Checkout Price
$prices['autoship_percent_discount'] = autoship_percent_discount( $product, array( 'price' => $prices['regular_price'], 'discount' => $prices['autoship_checkout_price'] ) );
// Get the calculated Percent Discount for the Recurring Price
$prices['autoship_percent_recurring_discount']= autoship_percent_recurring_discount( $product, array( 'price' => $prices['regular_price'], 'discount' => $prices['autoship_recurring_price'] ) );
return apply_filters('autoship_all_prices_array', $prices, $product_id, $product );
}