Get rule title against product
Fetch the title of a rule applied to a specific product.
/**
* Get the discount details of given product with custom price
* @param $price float/integer
* @param $product object (Product object Example: wc_get_product($product_id))
* @param $quantity int
* @param $custom_price float/integer (0 for calculate discount from product price)
* @param $return_details string (Default value 'discounted_price' accepted values = 'discounted_price','all')
* @param $manual_request boolean (Default value false: pass this as true for get discount even if there is no item in cart)
* @param $is_cart boolean (Default value true)
* @return array|float|int - is product has no discounts, returns $price;else return array of discount details based on $return_details
*/
//apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', $price, $product, $quantity, $custom_price, $return_details, $manual_request, $is_cart);
$discount = apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', $price_html, $product, 1, 0, 'all', 'true');
if( $discount !== false && isset($discount['total_discount_details']) && !empty($discount['total_discount_details']) ){
$total_discounts = $discount['total_discount_details'];
foreach($total_discounts as $rule_id => $detail){
if ( class_exists('\Wdr\App\Controllers\ManageDiscount')) {
$rules = \Wdr\App\Controllers\ManageDiscount::$available_rules;
$rule_titles = array();
if(!empty($rules) && is_array($rules)){
foreach ($rules as $rule){
$id = 0;
if($rule->rule->enabled == 1){
$id = $rule->rule->id;
//get title
//$rule_titles[id] = $this->rule->title;
}
if($rule_id == $id){
echo $this->rule->title;
}
}
}
}
}
}