Skip to content

Merge 0.8 into 1.x#1528

Closed
glennjacobs wants to merge 33 commits into1.xfrom
0.8
Closed

Merge 0.8 into 1.x#1528
glennjacobs wants to merge 33 commits into1.xfrom
0.8

Conversation

@glennjacobs
Copy link
Contributor

@glennjacobs glennjacobs commented Jan 31, 2024

  • Sort the gazillion merge conflicts

glennjacobs and others added 29 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>
@vercel
Copy link

vercel bot commented Jan 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lunar-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 9, 2024 8:32am

@glennjacobs glennjacobs added this to the v1.0 milestone Jan 31, 2024
@alecritson
Copy link
Collaborator

Closing in favour of #1601 since we should be using an intermediary brach when merging between versions as fixing the conflicts would require commits directly on the 0.8 branch, which should remain intact.

@alecritson alecritson closed this Mar 1, 2024
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.