Skip to content

Chore - Merge 0.8 into 1.0#1601

Merged
alecritson merged 40 commits into1.xfrom
chore/merge-08-into-1
Mar 5, 2024
Merged

Chore - Merge 0.8 into 1.0#1601
alecritson merged 40 commits into1.xfrom
chore/merge-08-into-1

Conversation

@alecritson
Copy link
Collaborator

Merge 0.8 into 1.0

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>
se09deluca and others added 4 commits February 9, 2024 08:27
Fix typo in pricing tiers strapline.
# Conflicts:
#	.gitignore
#	docs/.vitepress/config.js
#	docs/core/contributing.md
#	docs/core/upgrading.md
#	docs/package.json
#	packages/admin/resources/lang/en/global.php
#	packages/admin/resources/lang/en/partials.php
#	packages/admin/resources/views/livewire/components/orders/capture.blade.php
#	packages/admin/resources/views/partials/navigation/taxes.blade.php
#	packages/admin/src/AdminHubServiceProvider.php
#	packages/admin/src/Http/Livewire/Components/ActivityLogFeed.php
#	packages/admin/src/Http/Livewire/Components/Orders/OrderStatus.php
#	packages/admin/src/Http/Livewire/Components/Products/Tables/ProductVariantsTable.php
#	packages/admin/src/Http/Livewire/Components/Settings/Attributes/AttributeGroupEdit.php
#	packages/admin/src/Http/Livewire/Dashboard.php
#	packages/admin/src/Menu/SettingsMenu.php
#	packages/admin/tests/Feature/Http/Livewire/Pages/Products/ProductShowTest.php
#	packages/admin/tests/Unit/Http/Livewire/Components/Orders/OrderShowTest.php
#	packages/core/database/state/ConvertTaxbreakdown.php
#	packages/core/src/Base/StandardMediaConversions.php
#	packages/core/src/Managers/DiscountManager.php
#	packages/core/src/Models/Product.php
#	packages/core/src/Models/ProductOption.php
#	packages/core/src/Models/ProductOptionValue.php
#	packages/core/tests/Unit/Actions/Taxes/GetTaxZoneTest.php
#	packages/core/tests/Unit/DiscountTypes/AmountOffTest.php
#	packages/core/tests/Unit/Models/CartTest.php
#	packages/core/tests/Unit/Models/OrderTest.php
#	packages/core/tests/Unit/Models/ProductTest.php
#	packages/core/tests/Unit/Pipelines/Cart/CalculateLinesTest.php
#	packages/core/tests/Unit/Search/OrderIndexerTest.php
#	packages/opayo/.gitattributes
#	packages/stripe/.gitattributes
#	tests/core/Unit/Console/CartPruneTest.php
#	utils/scout-database-engine/src/DatabaseEngine.php
@alecritson alecritson requested a review from glennjacobs March 1, 2024 10:45
@vercel
Copy link

vercel bot commented Mar 1, 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 Mar 5, 2024 8:17am

@alecritson alecritson mentioned this pull request Mar 1, 2024
1 task
@alecritson alecritson marked this pull request as draft March 1, 2024 10:48
@alecritson alecritson marked this pull request as ready for review March 1, 2024 11:06
@glennjacobs glennjacobs added this to the v1.0 milestone Mar 4, 2024
@alecritson alecritson merged commit 9cc76c4 into 1.x Mar 5, 2024
@alecritson alecritson deleted the chore/merge-08-into-1 branch March 5, 2024 08:52
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.