Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Safemood committed Apr 7, 2024
1 parent 67b43c7 commit bcd684c
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions README.md
@@ -1,7 +1,6 @@

# Laravel Discountify for dynamic discounts with custom conditions.


[![Latest Version on Packagist](https://img.shields.io/packagist/v/safemood/discountify.svg?style=flat-square)](https://packagist.org/packages/safemood/discountify)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/safemood/discountify/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/safemood/discountify/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/safemood/discountify/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/safemood/discountify/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
Expand Down Expand Up @@ -114,6 +113,10 @@ Discountify::setItems($items)

$total = Discountify::total();

// Calculate total amount with detailed breakdown
// (array contains total, subtotal, tax amount, total after discount, savings, tax rate, discount rate)
$total = Discountify::totalDetailed();

// Calculate the total amount with the applied global discount

$totalWithDiscount = Discountify::totalWithDiscount();
Expand All @@ -122,10 +125,19 @@ $totalWithDiscount = Discountify::totalWithDiscount();

$totalWithTaxes = Discountify::tax();

// Calculate the total tax amount based on the given tax rate (19 in this case)
// Calculate the total tax amount based on the given tax rate (19 in this case) (before discounts)

$taxAmount = Discountify::taxAmount(19);

// Calculate tax amount with tax applied after discounts

$taxAmount = Discountify::calculateTaxAmount(19, true);


// Calculate the amount saved
$savings = Discountify::savings();


```
### Dynamic Field Names
```php
Expand Down Expand Up @@ -242,7 +254,7 @@ class OrderTotalDiscount implements ConditionInterface

### Event Tracking

You can listen for the `DiscountAppliedEvent` using Laravel's Event system.
You can listen for the `DiscountAppliedEvent` and `CouponAppliedEvent` using Laravel's Event system.


Ensure the following configuration in the discountify.php file:
Expand All @@ -264,6 +276,12 @@ public function boot(): void
// Ex : Mail to costumer
// dd($event);
});

Event::listen(function (CouponAppliedEvent $event) { // Added
// Your event handling logic for CouponAppliedEvent here
// Example: Log coupon usage
// dd($event);
});
}
```
Check the [Laravel Events documentation](https://laravel.com/docs/10.x/events#registering-events-and-listeners) for more details.
Expand Down

0 comments on commit bcd684c

Please sign in to comment.