Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 0.8 #1743

Merged
merged 74 commits into from
May 22, 2024
Merged

Merge 0.8 #1743

merged 74 commits into from
May 22, 2024

Conversation

glennjacobs
Copy link
Contributor

@glennjacobs glennjacobs commented May 13, 2024

Merges changes from the 0.8 branch into 1.x.

glennjacobs and others added 30 commits December 4, 2023 15:57
using same listener name as filament panel
Fixes a typo in the example of CartSession::addLines usage.

The implementation of
[addLines](https://github.com/lunarphp/lunar/blob/7f41cf66ebc96ee7465a84c8a4c4dd24228bf47d/packages/core/src/Models/Cart.php#L337C10-L337C10)
currently expects a purchasable instance as below:
```php
public function add(Purchasable $purchasable, int $quantity = 1, array $meta = [], bool $refresh = true): Cart
{
    foreach (config('lunar.cart.validators.add_to_cart', []) as $action) {
        // Throws a validation exception?
        app($action)->using(
            cart: $this,
            purchasable: $purchasable,
            quantity: $quantity,
            meta: $meta
        )->validate();
    }

    return app(
        config('lunar.cart.actions.add_to_cart', AddOrUpdatePurchasable::class)
    )->execute($this, $purchasable, $quantity, $meta)
        ->then(fn () => $refresh ? $this->refresh()->calculate() : $this);
}

public function addLines(iterable $lines): Cart
{
    DB::transaction(function () use ($lines) {
        collect($lines)->each(function ($line) {
            $this->add(
                purchasable: $line['purchasable'],
                quantity: $line['quantity'],
                meta: (array) ($line['meta'] ?? null),
                refresh: false
            );
        });
    });

    return $this->refresh()->calculate();
}
```

Co-authored-by: Alec Ritson <hello@itsalec.co.uk>
This PR adds a command `lunar:prune:carts` and some new config params
under `lunar.cart.prune_tables` to determine how pruning should be
carried out.

I opted for using a pipeline for amending the query, as we ultimately
always seem to end up there.

I've tried to default to some sensible settings (90 days, dont prune
carts with orders associated).

If pruning is enabled we automatically add a daily task rather then
needing the developer to do it.

---------

Co-authored-by: Glenn Jacobs <glenn@neondigital.co.uk>
This PR fix issue [#1355](#1355)

DatabaseEngine no longer espace query on SQL

The engine execute query without quote and generate syntax error on
database server
This PR adds the ability to reset the DiscountManager query cache - this
is necessary if you add a discount coupon and want to update the cart
totals in the same request.

---------

Co-authored-by: Glenn Jacobs <glenn@neondigital.co.uk>
I am getting an error when the transaction model is null when viewing an
order with only an intent transaction. Adding this null check fixes the
error.

Co-authored-by: Glenn Jacobs <glenn@neondigital.co.uk>
Regression test to ensure that `mappedAttributes` returns the correct
class and also the `collections` relationship on products has the
correct model referenced

Co-authored-by: Glenn Jacobs <glenn@neondigital.co.uk>
@glennjacobs
Copy link
Contributor Author

@alecritson do you think we should have the .github folders on each package?

packages/admin/src/Models/Staff.php Outdated Show resolved Hide resolved
@alecritson
Copy link
Collaborator

@alecritson do you think we should have the .github folders on each package?

I assume we need them because they have specific workflows which auto close PRs?

@glennjacobs
Copy link
Contributor Author

@alecritson do you think we should have the .github folders on each package?

I assume we need them because they have specific workflows which auto close PRs?

Yeah, they're to auto-close PRs on the read-only repos. It could be argued that all the packages should have them.

alecritson
alecritson previously approved these changes May 22, 2024
@glennjacobs glennjacobs merged commit 5e7bd8a into 1.x May 22, 2024
23 checks passed
@glennjacobs glennjacobs deleted the merge-0.8 branch May 22, 2024 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet