Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 7c9c9c2
Author: Alec Ritson <hello@itsalec.co.uk>
Date:   Fri Mar 24 14:18:08 2023 +0000

    Update changelogs (#900)

commit 04a1887
Author: Alec Ritson <hello@itsalec.co.uk>
Date:   Fri Mar 24 13:51:29 2023 +0000

    :beer:

commit 6f28e8d
Author: Ryan Mitchell <ryan@thoughtcollective.com>
Date:   Fri Mar 24 13:41:56 2023 +0000

    Add max user uses to discounts (#892)

    * Add ability to limit discount uses by users

    * Pint

    * Wrong relation

    * Use $cart->user instead of auth

    * Fix test bug

    * Fix test bugs

    * Change field type

    * Bug fixes

commit aff3916
Author: wychoong <67364036+wychoong@users.noreply.github.com>
Date:   Fri Mar 24 19:49:43 2023 +0800

    Cart meta cast (#895)

    * Squashed commit of the following:

    commit 02c2671
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Fri Feb 10 11:13:49 2023 +0000

        Update lines.blade.php (#849)

    commit 0780a1c
    Author: wychoong <67364036+wychoong@users.noreply.github.com>
    Date:   Fri Feb 10 18:41:36 2023 +0800

        Update CollectionTree.php (#835)

        Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

    commit e558799
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Fri Feb 10 09:47:16 2023 +0000

        :beer:

    commit 8fd4842
    Merge: df6f7f7 51af420
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Fri Feb 10 09:47:03 2023 +0000

        Merge branch '0.2' of github.com:lunarphp/lunar into 0.2

    commit df6f7f7
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Fri Feb 10 09:47:00 2023 +0000

        :beer:

    commit 51af420
    Author: wychoong <67364036+wychoong@users.noreply.github.com>
    Date:   Fri Feb 10 17:43:10 2023 +0800

        [0.2] Hotfix - fix pluck on null (#834)

        * fix pluck on null

        * Update AbstractDiscount.php

        ---------

        Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

    commit 7b5ce85
    Author: wychoong <67364036+wychoong@users.noreply.github.com>
    Date:   Fri Feb 10 17:16:50 2023 +0800

        [0.2] Fix/discount by product (#841)

        * fix

        * add test

        * fix discount minSpend precision

        * fix discount condition logic

        * fix

        * fix coupon check

    commit 72f8454
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Fri Feb 10 09:16:16 2023 +0000

        Hotfix [0.2] - Wrap customer group in array (#846)

        * Wrap customer group in array

        * Update ProductVariantTest.php

    commit b8773d3
    Author: Ryan Mitchell <ryan@thoughtcollective.com>
    Date:   Wed Feb 8 20:43:09 2023 +0000

        When DB::table() is used make sure connection is passed (#826)

    commit 650d9db
    Merge: dcd39cc de20aff
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Wed Feb 1 09:57:04 2023 +0000

        Merge branch 'main' into 0.2

    commit dcd39cc
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Tue Jan 31 07:29:15 2023 +0000

        :beer:

    * Squashed commit of the following:

    commit 1a362cc
    Author: Ivanka Todorova <1038697+fakeheal@users.noreply.github.com>
    Date:   Tue Feb 14 13:25:25 2023 +0200

        Fix validation of attributes of type TranslatedText (#839)

        * fix: validation rules to be applied on elements in `TranslatedText`

        * fix: "reset" the validation rules applied to each sub-field in `TranslatedText`

        * chore: add tests for validating attribute fields (required/optional) and their additional rules

        ---------

        Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

    commit 6c1ab08
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Tue Feb 14 10:58:15 2023 +0000

        [0.2] Hotfix - Fix collection name on creation (#852)

        * Squashed commit of the following:

        commit 02c2671
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Fri Feb 10 11:13:49 2023 +0000

            Update lines.blade.php (#849)

        commit 0780a1c
        Author: wychoong <67364036+wychoong@users.noreply.github.com>
        Date:   Fri Feb 10 18:41:36 2023 +0800

            Update CollectionTree.php (#835)

            Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

        commit e558799
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Fri Feb 10 09:47:16 2023 +0000

            :beer:

        commit 8fd4842
        Merge: df6f7f7 51af420
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Fri Feb 10 09:47:03 2023 +0000

            Merge branch '0.2' of github.com:lunarphp/lunar into 0.2

        commit df6f7f7
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Fri Feb 10 09:47:00 2023 +0000

            :beer:

        commit 51af420
        Author: wychoong <67364036+wychoong@users.noreply.github.com>
        Date:   Fri Feb 10 17:43:10 2023 +0800

            [0.2] Hotfix - fix pluck on null (#834)

            * fix pluck on null

            * Update AbstractDiscount.php

            ---------

            Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

        commit 7b5ce85
        Author: wychoong <67364036+wychoong@users.noreply.github.com>
        Date:   Fri Feb 10 17:16:50 2023 +0800

            [0.2] Fix/discount by product (#841)

            * fix

            * add test

            * fix discount minSpend precision

            * fix discount condition logic

            * fix

            * fix coupon check

        commit 72f8454
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Fri Feb 10 09:16:16 2023 +0000

            Hotfix [0.2] - Wrap customer group in array (#846)

            * Wrap customer group in array

            * Update ProductVariantTest.php

        commit b8773d3
        Author: Ryan Mitchell <ryan@thoughtcollective.com>
        Date:   Wed Feb 8 20:43:09 2023 +0000

            When DB::table() is used make sure connection is passed (#826)

        commit 650d9db
        Merge: dcd39cc de20aff
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Wed Feb 1 09:57:04 2023 +0000

            Merge branch 'main' into 0.2

        commit dcd39cc
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Tue Jan 31 07:29:15 2023 +0000

            :beer:

        * Check for attribute type when creating

    commit 0942397
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Tue Feb 14 10:57:37 2023 +0000

        Update HasImages.php (#853)

    * Release 0.2-rc2 (#873)

    * Update changelogs

    * Update CHANGELOG.md

    * Allow textarea component maxlength to be overridden (#880)

    * Allow textarea component maxlength to be overridden

    * Add changelog

    * Update Cart.php

    ---------

    Co-authored-by: Alec Ritson <hello@itsalec.co.uk>
    Co-authored-by: Ryan Mitchell <ryan@thoughtcollective.com>

commit b6a6a8c
Author: Alec Ritson <hello@itsalec.co.uk>
Date:   Fri Mar 24 11:22:15 2023 +0000

    Add `wire:ignore` to bulk actions list (#888)

commit 76471db
Author: wychoong <67364036+wychoong@users.noreply.github.com>
Date:   Fri Mar 24 19:21:51 2023 +0800

    clear cached properties on model refresh (#896)

    * Update Cart.php

    * Update CachesProperties.php

    * Update Cart.php

    ---------

    Co-authored-by: Glenn Jacobs <glenn@neondigital.co.uk>

commit d9ca112
Author: Alec Ritson <hello@itsalec.co.uk>
Date:   Fri Mar 24 11:13:50 2023 +0000

    Tweak discount logic (#894)

commit a599243
Author: Kyle Anderson <kylekanderson@gmail.com>
Date:   Fri Mar 24 07:09:59 2023 -0400

    calculate cartline unit price based on cart user, rather than Auth::user (#897)

    * Squashed commit of the following:

    commit 02c2671
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Fri Feb 10 11:13:49 2023 +0000

        Update lines.blade.php (#849)

    commit 0780a1c
    Author: wychoong <67364036+wychoong@users.noreply.github.com>
    Date:   Fri Feb 10 18:41:36 2023 +0800

        Update CollectionTree.php (#835)

        Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

    commit e558799
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Fri Feb 10 09:47:16 2023 +0000

        :beer:

    commit 8fd4842
    Merge: df6f7f7 51af420
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Fri Feb 10 09:47:03 2023 +0000

        Merge branch '0.2' of github.com:lunarphp/lunar into 0.2

    commit df6f7f7
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Fri Feb 10 09:47:00 2023 +0000

        :beer:

    commit 51af420
    Author: wychoong <67364036+wychoong@users.noreply.github.com>
    Date:   Fri Feb 10 17:43:10 2023 +0800

        [0.2] Hotfix - fix pluck on null (#834)

        * fix pluck on null

        * Update AbstractDiscount.php

        ---------

        Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

    commit 7b5ce85
    Author: wychoong <67364036+wychoong@users.noreply.github.com>
    Date:   Fri Feb 10 17:16:50 2023 +0800

        [0.2] Fix/discount by product (#841)

        * fix

        * add test

        * fix discount minSpend precision

        * fix discount condition logic

        * fix

        * fix coupon check

    commit 72f8454
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Fri Feb 10 09:16:16 2023 +0000

        Hotfix [0.2] - Wrap customer group in array (#846)

        * Wrap customer group in array

        * Update ProductVariantTest.php

    commit b8773d3
    Author: Ryan Mitchell <ryan@thoughtcollective.com>
    Date:   Wed Feb 8 20:43:09 2023 +0000

        When DB::table() is used make sure connection is passed (#826)

    commit 650d9db
    Merge: dcd39cc de20aff
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Wed Feb 1 09:57:04 2023 +0000

        Merge branch 'main' into 0.2

    commit dcd39cc
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Tue Jan 31 07:29:15 2023 +0000

        :beer:

    * Squashed commit of the following:

    commit 1a362cc
    Author: Ivanka Todorova <1038697+fakeheal@users.noreply.github.com>
    Date:   Tue Feb 14 13:25:25 2023 +0200

        Fix validation of attributes of type TranslatedText (#839)

        * fix: validation rules to be applied on elements in `TranslatedText`

        * fix: "reset" the validation rules applied to each sub-field in `TranslatedText`

        * chore: add tests for validating attribute fields (required/optional) and their additional rules

        ---------

        Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

    commit 6c1ab08
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Tue Feb 14 10:58:15 2023 +0000

        [0.2] Hotfix - Fix collection name on creation (#852)

        * Squashed commit of the following:

        commit 02c2671
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Fri Feb 10 11:13:49 2023 +0000

            Update lines.blade.php (#849)

        commit 0780a1c
        Author: wychoong <67364036+wychoong@users.noreply.github.com>
        Date:   Fri Feb 10 18:41:36 2023 +0800

            Update CollectionTree.php (#835)

            Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

        commit e558799
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Fri Feb 10 09:47:16 2023 +0000

            :beer:

        commit 8fd4842
        Merge: df6f7f7 51af420
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Fri Feb 10 09:47:03 2023 +0000

            Merge branch '0.2' of github.com:lunarphp/lunar into 0.2

        commit df6f7f7
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Fri Feb 10 09:47:00 2023 +0000

            :beer:

        commit 51af420
        Author: wychoong <67364036+wychoong@users.noreply.github.com>
        Date:   Fri Feb 10 17:43:10 2023 +0800

            [0.2] Hotfix - fix pluck on null (#834)

            * fix pluck on null

            * Update AbstractDiscount.php

            ---------

            Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

        commit 7b5ce85
        Author: wychoong <67364036+wychoong@users.noreply.github.com>
        Date:   Fri Feb 10 17:16:50 2023 +0800

            [0.2] Fix/discount by product (#841)

            * fix

            * add test

            * fix discount minSpend precision

            * fix discount condition logic

            * fix

            * fix coupon check

        commit 72f8454
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Fri Feb 10 09:16:16 2023 +0000

            Hotfix [0.2] - Wrap customer group in array (#846)

            * Wrap customer group in array

            * Update ProductVariantTest.php

        commit b8773d3
        Author: Ryan Mitchell <ryan@thoughtcollective.com>
        Date:   Wed Feb 8 20:43:09 2023 +0000

            When DB::table() is used make sure connection is passed (#826)

        commit 650d9db
        Merge: dcd39cc de20aff
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Wed Feb 1 09:57:04 2023 +0000

            Merge branch 'main' into 0.2

        commit dcd39cc
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Tue Jan 31 07:29:15 2023 +0000

            :beer:

        * Check for attribute type when creating

    commit 0942397
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Tue Feb 14 10:57:37 2023 +0000

        Update HasImages.php (#853)

    * Release 0.2-rc2 (#873)

    * Update changelogs

    * Update CHANGELOG.md

    * Allow textarea component maxlength to be overridden (#880)

    * Allow textarea component maxlength to be overridden

    * Add changelog

    * calculate cartline unit price based on cart user, rather than Auth::user

    ---------

    Co-authored-by: Alec Ritson <hello@itsalec.co.uk>
    Co-authored-by: Ryan Mitchell <ryan@thoughtcollective.com>
    Co-authored-by: Kyle Anderson <kyle@creative2.com>

commit 680f317
Author: Ryan Mitchell <ryan@thoughtcollective.com>
Date:   Fri Mar 10 13:40:38 2023 +0000

    Discount breakdown (#884)

    * Add concept of DiscountBreakdown to cart

    * Should have been $rewardLine

    * Bug fix

    * Use a DTO for affected discount lines

    * Line not lines

    * Fix bug

    * Simplify DTOs

    * Apply to `AmountOff` discounts

    * Add discount breakdown to orders

    * 🍺

    * Bug fix

    * Fix up casting... if its not a collection then we dont need to do anything

    * Make discount_breakdown nullable

    * Create method in abstract class for adding breakdowns

    * Tests

    * Place column before discount_total

    * Remove un-used code

    * Use toJson()

    * Avoid duplication in CreateOrder

    * Formatting

    * Add test to ensure discount_breakdown is added to orders

    * Add docs

    * Add changelog

    ---------

    Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

commit e799ab1
Author: Ryan Mitchell <ryan@thoughtcollective.com>
Date:   Fri Mar 10 09:39:06 2023 +0000

    Fix tax breakdown on save (#887)

    * Tax breakdown fix - if total is a price then save its value

    * Implement `SerializesCastableAttributes`

    * Add full param list

    * Update test coverage

    * Use toJson()

    ---------

    Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

commit 86a509c
Author: Ryan Mitchell <ryan@thoughtcollective.com>
Date:   Thu Mar 9 15:06:15 2023 +0000

    Add shipping tax correctly (#889)

commit be5c400
Author: Glenn Jacobs <glenn@neondigital.co.uk>
Date:   Thu Feb 23 10:36:54 2023 +0000

    Adding Validations menu item which was missing
  • Loading branch information
alecritson committed Mar 24, 2023
1 parent fac9149 commit 9e4ad8f
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 34 deletions.
62 changes: 36 additions & 26 deletions packages/admin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## 0.2-RC3

### Fixed

- Fixed an issue that prevented bulk actions from remembering the selected rows.

### Added

- Added the ability to specify the maximum length of textarea fields in the admin hub

## 0.2-RC2

### Fixed
Expand All @@ -26,38 +36,38 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Fixed

* [0.2] Hotfix - Upload Image by @Aslam97 in https://github.com/lunarphp/lunar/pull/810
* Hotfix [0.2] - Fix duplicate language code on tests by @alecritson in https://github.com/lunarphp/lunar/pull/802
* Hotfix [0.2] - UI Tweaks by @alecritson in https://github.com/lunarphp/lunar/pull/805
* fix blade directive issue causing error on products index page in hub by @kylekanderson in https://github.com/lunarphp/lunar/pull/801
* [0.2] Hotfix - Fix save form layout and clean up by @alecritson in https://github.com/lunarphp/lunar/pull/795
* fix images key by @wychoong in https://github.com/lunarphp/lunar/pull/789
* Hotfix - Fix discount saving by @alecritson in https://github.com/lunarphp/lunar/pull/793
* [0.2] Hotfix - Check for variants existence when saving images. by @alecritson in https://github.com/lunarphp/lunar/pull/778
* [0.2] Hotfix - Fix product/collection syncing by @alecritson in https://github.com/lunarphp/lunar/pull/781
* [0.2] Feat - Delay loading Collection products when large amounts by @alecritson in https://github.com/lunarphp/lunar/pull/770
* [0.2] Feat - Add fallback to images by @charlielangridge in https://github.com/lunarphp/lunar/pull/682
- [0.2] Hotfix - Upload Image by @Aslam97 in https://github.com/lunarphp/lunar/pull/810
- Hotfix [0.2] - Fix duplicate language code on tests by @alecritson in https://github.com/lunarphp/lunar/pull/802
- Hotfix [0.2] - UI Tweaks by @alecritson in https://github.com/lunarphp/lunar/pull/805
- fix blade directive issue causing error on products index page in hub by @kylekanderson in https://github.com/lunarphp/lunar/pull/801
- [0.2] Hotfix - Fix save form layout and clean up by @alecritson in https://github.com/lunarphp/lunar/pull/795
- fix images key by @wychoong in https://github.com/lunarphp/lunar/pull/789
- Hotfix - Fix discount saving by @alecritson in https://github.com/lunarphp/lunar/pull/793
- [0.2] Hotfix - Check for variants existence when saving images. by @alecritson in https://github.com/lunarphp/lunar/pull/778
- [0.2] Hotfix - Fix product/collection syncing by @alecritson in https://github.com/lunarphp/lunar/pull/781
- [0.2] Feat - Delay loading Collection products when large amounts by @alecritson in https://github.com/lunarphp/lunar/pull/770
- [0.2] Feat - Add fallback to images by @charlielangridge in https://github.com/lunarphp/lunar/pull/682

### Changed

* ux updates by @wychoong in https://github.com/lunarphp/lunar/pull/812
* Change of UI on discount limitations to use popover by @ryanmitchell in https://github.com/lunarphp/lunar/pull/796
* Improve UX for image manager by @rubenvanerk in https://github.com/lunarphp/lunar/pull/806
* [0.2] Feat - Menu layout refactor by @alecritson in https://github.com/lunarphp/lunar/pull/794
* [0.2] Nested menu by @markmead in https://github.com/lunarphp/lunar/pull/680
- ux updates by @wychoong in https://github.com/lunarphp/lunar/pull/812
- Change of UI on discount limitations to use popover by @ryanmitchell in https://github.com/lunarphp/lunar/pull/796
- Improve UX for image manager by @rubenvanerk in https://github.com/lunarphp/lunar/pull/806
- [0.2] Feat - Menu layout refactor by @alecritson in https://github.com/lunarphp/lunar/pull/794
- [0.2] Nested menu by @markmead in https://github.com/lunarphp/lunar/pull/680

### Added

* [0.2] Preview/View URLs for Products by @alecritson in https://github.com/lunarphp/lunar/pull/772
* [0.2] Image editor by @wychoong in https://github.com/lunarphp/lunar/pull/505
* Feat [0.2] - Enable validation extending on product variant by @alecritson in https://github.com/lunarphp/lunar/pull/824
* Add products to discount limitations by @ryanmitchell in https://github.com/lunarphp/lunar/pull/813
* [0.2] File upload field type by @alecritson in https://github.com/lunarphp/lunar/pull/452
* [0.2] Manage customer groups by @adam-code-labx in https://github.com/lunarphp/lunar/pull/496
* [0.2] Settings - Manage Product Options by @adam-code-labx in https://github.com/lunarphp/lunar/pull/419
* [0.2] Allow extending of validation rules by @wychoong in https://github.com/lunarphp/lunar/pull/443
* [0.2] Discounts by @alecritson in https://github.com/lunarphp/lunar/pull/324
* [0.2] Add tags to orders by @alecritson in https://github.com/lunarphp/lunar/pull/433
- [0.2] Preview/View URLs for Products by @alecritson in https://github.com/lunarphp/lunar/pull/772
- [0.2] Image editor by @wychoong in https://github.com/lunarphp/lunar/pull/505
- Feat [0.2] - Enable validation extending on product variant by @alecritson in https://github.com/lunarphp/lunar/pull/824
- Add products to discount limitations by @ryanmitchell in https://github.com/lunarphp/lunar/pull/813
- [0.2] File upload field type by @alecritson in https://github.com/lunarphp/lunar/pull/452
- [0.2] Manage customer groups by @adam-code-labx in https://github.com/lunarphp/lunar/pull/496
- [0.2] Settings - Manage Product Options by @adam-code-labx in https://github.com/lunarphp/lunar/pull/419
- [0.2] Allow extending of validation rules by @wychoong in https://github.com/lunarphp/lunar/pull/443
- [0.2] Discounts by @alecritson in https://github.com/lunarphp/lunar/pull/324
- [0.2] Add tags to orders by @alecritson in https://github.com/lunarphp/lunar/pull/433

**Full Changelog**: https://github.com/lunarphp/lunar/compare/0.1.4...0.2-rc1

Expand Down
15 changes: 14 additions & 1 deletion packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,29 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Added

- Added the ability to specify the maximum length of textarea fields in the admin hub

## 0.2-RC3

### Fixed

- Fixed serialisation issue on `tax_breakdown` when creating an order.
- Cart cached properties should now refresh correctly when calculating.

### Changed

- The GetUnitPrice action will now use the cart user if present rather than the authenticated user.
- Discounts will now take other discounts into account before they apply their own logic.
- Cart meta is now cast to an `array` when adding a purchasable.

### Added

- Added the ability to specify the maximum length of textarea fields in the admin hub
- Added discount breakdowns to cart and order models in https://github.com/lunarphp/lunar/pull/884
- Added max uses by user on discounts.

## 0.2-RC2

Expand Down
15 changes: 15 additions & 0 deletions packages/core/src/Base/Traits/CachesProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ public function refresh()
return $this;
}

public function refresh()
{
parent::refresh();

$ro = new ReflectionClass($this);

foreach ($this->cachableProperties as $property) {
$defaultValue = $ro->getProperty($property)->getDefaultValue();

$this->{$property} = $defaultValue;
}

return $this;
}

/**
* Returns a unique key for the cache.
*
Expand Down
8 changes: 2 additions & 6 deletions packages/core/src/DiscountTypes/BuyXGetY.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public function apply(Cart $cart): Cart
$maxRewardQty
);


if (! $totalRewardQty) {
return $cart;
}
Expand All @@ -95,19 +94,17 @@ public function apply(Cart $cart): Cart
});
})->sortBy('subTotal.value');


foreach ($rewardLines as $rewardLine) {
if (! $remainingRewardQty) {
continue;
}

$remainder = $rewardLine->quantity % $remainingRewardQty;


$qtyToAllocate = (int) round(($remainingRewardQty - $remainder) / $rewardLine->quantity);

if (!$remainder && $remainingRewardQty < $rewardLine->quantity) {
$qtyToAllocate = $remainingRewardQty;
if (! $remainder && $remainingRewardQty < $rewardLine->quantity) {
$qtyToAllocate = $remainingRewardQty;
}

if (! $qtyToAllocate) {
Expand All @@ -119,7 +116,6 @@ public function apply(Cart $cart): Cart
quantity: $qtyToAllocate
));


$conditionQtyToAllocate = $qtyToAllocate * $rewardQty;
$conditions->each(function ($conditionLine) use ($affectedLines, &$conditionQtyToAllocate) {
if (! $conditionQtyToAllocate) {
Expand Down
1 change: 0 additions & 1 deletion packages/core/tests/Unit/DiscountTypes/BuyXGetYTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,6 @@ public function can_apply_multiple_different_discounts()
/**
* Discount set up.
*/

$discountA = Discount::factory()->create([
'type' => BuyXGetY::class,
'priority' => 1,
Expand Down

0 comments on commit 9e4ad8f

Please sign in to comment.