Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sarancartrabbit/6d859abb98f1d8b99c1ce6a61a3835d5 to your computer and use it in GitHub Desktop.
Save sarancartrabbit/6d859abb98f1d8b99c1ce6a61a3835d5 to your computer and use it in GitHub Desktop.
Discount rules v2: Product based get discount price
add_filter('wc_add_to_cart_message_html', function ($message, $products, $show_qty){
foreach ( $products as $product_id => $qty ) {
$product = wc_get_product( $product_id);
$product_price = $product->get_price();
$discount = apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', $product_price, $product, $qty, $product_price, 'discounted_price', false, true);
if($discount !== false) {
$message .= " Discounted price: ". $discount; //HERE YOU GET DISCOUNTED PRICE
}
}
return $message;
}, 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment