Created
February 4, 2022 07:10
-
-
Save AshlinRejo/87d4d69a0a115f54ee025cd503cefab8 to your computer and use it in GitHub Desktop.
Discount rules v2: You save text on line item price
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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