lunarphp/lunar

Unable to create order

infinitodk opened this issue · 8 comments

  • Lunar version: 1.0-Beta
  • Laravel Version: 11
  • PHP Version: 8.2.1
  • Database Driver & Version:

Expected Behaviour:

Creating order from basket should work

Actual Behaviour:

Getting Shipping breakdown must be instance of Lunar\Base\ValueObjects\Cart\ShippingBreakdown.

Works in previously versions.

Steps To Reproduce:

// Create a new cart for the user
$cart = Cart::create([
'currency_id' => Currency::first()->id,
'channel_id' => Channel::first()->id,
'user_id' => $user->id,
]);

        $cart->lines()->create([
            'purchasable_type' => ProductVariant::class,
            'purchasable_id' => $this->product->variants()->first()->id,
            'quantity' => 1,
        ]);

        // Set the billing address for the cart
        $cart->setBillingAddress([
            'first_name' => $user->name,
            'last_name' => $user->name,
            'line_one' => '123',
            'city' => 'Greenified',
            'postcode' => 2600,
            'country_id' => 61,
        ]);

        // Create the order from the cart
        $order = $cart->createOrder();

public function boot(): void
{
$this->app['db.schema']->morphUsingUuids();

    ModelManifest::replace(ProductContract::class, \App\Models\Product::class);
    ModelManifest::replace(OrderContract::class, \App\Models\Order::class);
    ModelManifest::replace(CartContract::class, \App\Models\Cart::class);
}

removing these makes it work, all of the abovementioned models extern their respective Lunar counterparts

Hello, I also came across this problem and already spent hours debugging this problem already and I think I might have a solution as drafted here: #1932 and implemented here: #1933

@infinitodk can you try if it fixes your issues as well?

"require": {
    "lunarphp/lunar": "dev-update-container-resolution as 1.0.0-beta.1",
},
"repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/theimerj/lunar.git"
    }
]

Will try, came to the same conclusion as you, that a serialization happened to early.

I also noticed that it references the classes wrong in polymorphic relationships aswell.

Will try, came to the same conclusion as you, that a serialization happened to early.

I also noticed that it references the classes wrong in polymorphic relationships aswell.

You are right, addressed by this commit: edb019f

I have the same problem and installing your repository indeed solves the problem for now.

We have a patch #1944 which should solve this issue in the next release 🤞

Unfortunatelly this does not solve all the problems introduced with the updated model extending as shown here: repl6669#2. I made a branch out of 1.x and updated the tests so they are run with all models extended.