Last active
December 3, 2025 11:43
-
-
Save goranefbl/3b91c1740358d8a7f60982c743df0223 to your computer and use it in GitHub Desktop.
Give points based on order total
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
| <?php | |
| add_filter('wpgens_loyalty_cart_points_after_discount', function($total_points, $cart, $discount_ratio) { | |
| // Calculate points based on actual cart total | |
| $cart_total = $cart->get_total('edit'); | |
| // Optional: Exclude shipping from points calculation | |
| $cart_total_without_shipping = $cart_total - $cart->get_shipping_total() - $cart->get_shipping_tax(); | |
| // 1 point for every 10 dollars spent | |
| return round($cart_total_without_shipping / 10); | |
| // Alternative: Include shipping in points calculation | |
| // return round($cart_total / 10); | |
| }, 10, 3); | |
| add_filter('wpgens_loyalty_order_points_after_discount', function($total_points, $order, $discount_ratio) { | |
| // Calculate points based on actual order total | |
| $order_total = $order->get_total(); | |
| // Optional: Exclude shipping from points calculation | |
| $order_total_without_shipping = $order_total - $order->get_shipping_total() - $order->get_shipping_tax(); | |
| // 1 point for every 10 dollars spent | |
| return round($order_total_without_shipping / 10); | |
| // Alternative: Include shipping in points calculation | |
| // return round($order_total / 10); | |
| }, 10, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment