Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AshlinRejo/87d4d69a0a115f54ee025cd503cefab8 to your computer and use it in GitHub Desktop.
Save AshlinRejo/87d4d69a0a115f54ee025cd503cefab8 to your computer and use it in GitHub Desktop.
Discount rules v2: You save text on line item price
add_filter('advanced_woo_discount_rules_cart_strikeout_price_html', function ($new_item_price_html, $item_price, $cart_item, $cart_item_key){
if(class_exists('\Wdr\App\Router')){
$manage_discount = \Wdr\App\Router::$manage_discount;
if(isset($manage_discount::$calculated_cart_item_discount) && isset($manage_discount::$calculated_cart_item_discount[$cart_item_key])){
$discounts = $manage_discount::$calculated_cart_item_discount[$cart_item_key];
if(isset($discounts['initial_price']) && isset($discounts['discounted_price'])){
$saved_amount = $discounts['initial_price']-$discounts['discounted_price'];
if($saved_amount > 0){
$saved_amount = \Wdr\App\Helpers\Woocommerce::formatPrice($saved_amount);
$new_item_price_html .= $manage_discount->getYouSavedText($saved_amount);
}
}
}
}
return $new_item_price_html;
}, 10, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment