Return to homepage
34/78. Showing child categories
This episode is for premium members only.

Take your skills to the next level with a premium membership.

Join now

Already a member? Sign in and enjoy.

Comments

Marwan

Hey Alex, I have a problem in class 38.

Error: Call to a member function map() on null

in this part:

1$filters = collect($this->queryFilters)
2->filter(fn ($filter) => !empty($filter))
3->recursive()
4->map(function ($value, $key) {
5 return $value->map(fn ($value) => $key . ' = "' . $value . '"');
6})
7->flatten()
8->join('AND');
9 
10dd($filters);

But my code is the same as yours, I've reviewed everything and I'm not finding the problem.

  • 0
Oluwatosin

Hi Alex, How do I download all the episodes at once?

  • 0
Kevin

Hello Alex, can subscribers have access to the latest source code please? Even if it's got bugs in it.

  • 0
Bilal

Another way of calculating the Order status I would like to share here:

On the Order.php model, I define this array:

1public $statuses = [
2 'placed_at' => 'Order Placed',
3 'packaged_at' => 'Order Packaged',
4 'shipped_at' => 'Order Shipped',
5];

Then, the status() function looks as follows:

1public function status()
2{
3 return collect($this->statuses)
4 ->last(fn ($status, $key) => filled($this->{$key}));
5}
  • 1
Lee

If anyone has a problem with this error

Undefined variable $meilisearchClientClassName

It is not the course

Laravel Scout just updated as of yesterday 06.01.2023 to 0.7.1

The package ahs a bug in it

This version works 0.7.0

Hope it helps

  • 1
Lee

Hi guys

Does anyone know how to change the limits on Meilisearch to bring more results down than the default of 20 please.

  • 0
Lee

Further to my posts final conclusion on Meilisearch

Not the best search engine in the world

Using the same techiques as in the video Alex only shows two products

Doing the same thing brings the variations up on the category where no products are actually in that category so when you click to choose that product you get an error

CALL TO MAP FUNCTION A STRING

Thats problem one problem two is that if you have 9 products in that category the Meislearch will only show 6 on v0.21.1

On later versions it only shows 5 products so if you want to show the customer 100 products in that category Meilisearch is useless

public $category; public function render() { $search = Product::search('', function ($meilisearch, string $query, array $options) {

1 $options['facetsDistribution'] = ['colour', 'size'];
2
3 return $meilisearch->search($query, $options);
4
5 })
6 ->raw();
7
8 $products = $this->category->products->find(collect($search['hits'])->pluck('id'));
9
10 return view('livewire.product-browser',[
11 'products' => $products
12 ]);
13}

As you can see exactly the same code as Alex types it bring back 6 and thats it.

  • 1
altrano

[Lecture 19] What is if we delete a user? this will fail because of the user_id in the Cart. I have fixed that with a deleting method in User model. Then also the Email verification will fail according to breeze provided tests, wich i fixed with set uuid in cart to nullable.

Not sure that are the best way for fixing that but it works with all tests green.

  • 0
Lee

I did this

public function closeyouraccount(User $user) { DB::table('orders') ->where('user_id', $user->id) ->update(['user_id' => null]);

1User::where('accountnumber', $user->accountnumber)
2 ->delete();
3Auth::logout();

And all other other tables

1 return redirect('/login')->with('status', 'Thankyou for being part of The Official Site Of Lee Weaver. You account was closed and data destroyed. Sorry to see you go.');
2}
  • 0
altrano

OK that seems to be better, thanks

  • 0
Lee

Hi guys question and I know this is nothing to do with what Alex has showed

Why is Meissearch only showing 6 products in the category when there are 18 and why are the filters that are not in that catgory showing any answers

  • 0
Lee

Update to my previous posts

For Meilsearch to work you would need Version 0.21.1

And this in your json

"meilisearch/meilisearch-php": "^0.19.0"

What Alex is showing is working on mine with these [versions but not repeat not work with newer versions

Facets Distribution was changed as of version 27 to facets which after trying too work with it with this course was a waste of time

So to conclude

When installing Meilisearch from their official website where you see

git checkout latest

Change latest to v0.21.1

Use the link for meilisearch.php in the composer json and what Alex is showing will work .

A note for Meiliseatrch developers is stop changing things and make the documentation easier to understand

It took me 3 days to work this out .

Hope it helps

  • 0
Lee

A lot of people are probably wondering why facets distribution is causing so many problems

In the video Alex explains that the filters must be added manually in Postman

There is another way by creating a Scout Service Provider and under register

$client = app(Client::class); $client->index('products') ->updateFilterableAttributes(['colour', 'fragrance', 'theme', 'price', 'category_ids', 'size']);

This is mine

Now this sort of works but when I click on the category the attributes for every product in the database comes up not just the category

Now why is this

If you notice Alex is using Meilisearch v0.25.0

In this version at the time of recording everything was upto date

However Meilisearch has upgraded by 5 versions since then

In the the video on the product browser Alex shows this

$options['facetsDistribution'] = ['colour', 'fragrance', 'theme', 'size'];

On version 30 of Meilsearch facetsDistribution is un recognised because Meilisearch has took this out

And with no easy to understand documentation form Meilsearch were gonna struggle

One person tried Facets and it worked I tried it and it doesnt work .

Thats why thers so many problems .

  • 0
altrano

Attributes and so on is defined in scout.php config file. https://laravel.com/docs/9.x/scout#configuring-filterable-data-for-meilisearch hope it will help. I am on the latest without any problems so far.

  • 0
Lee

Doing exactly waht you said

$search = Product::search('', function ($meilisearch, string $query, array $options) {

1$filters = collect($this->queryFilters)->filter(fn($filter) => !empty($filter))
2 ->recursive()
3 ->map(function ($value, $key) {
4 return $value->map(fn ($value) => $key . ' = "' . $value . '"');
5})
6->flatten()
7->join(' OR ');
8
9$options['filter'] = null;
10
11if($filters)
12{
13$options['filter'] = $filters;
14}
15
16if($this->priceRange['max'])
17{
18$options['facets'] = ['colour','fragrance', 'size', 'price', 'theme'];
19
20 $options['filter'] .= (isset($options['filter']) ? ' AND ' : '') . 'price < ' . $this->priceRange['max'];
21}
22
23
24
25return $meilisearch->search($query, $options);
26
27})
28->raw();
29
30$products = $this->category->products->find(collect($search['hits'])->pluck('id'));
31
32
33$maxPrice = $this->category->products->max('price');
34
35$this->priceRange['max'] = $this->priceRange['max'] ?: $maxPrice;
36
37
38return view('livewire.product-browser', [
39 'currencies' => $currencies,
40 'products' => $products,
41 'filters' => $search['facets'],
42 'maxPrice' => $maxPrice
43]);

Scout.php

'meilisearch' => [ 'host' => env('MEILISEARCH_HOST', 'http://localhost:7700'), 'key' => env('MEILISEARCH_KEY', null), 'settings' => [ \App\Models\Product::class => [ 'updateFilterableAttributes'=> ['colour','fragrance', 'theme', 'size', 'category_ids', 'price',], 'updateStopWords' => ['the','a','an'], ], ],

Error

Undefined array key "facets"

Latest version happens everytime so I dont know how you got it working ha ha

  • 0
altrano

"filterableAttributes" not "updateFilterableAttributes" adn also index-settings instead of settings

  • 0
altrano

https://laravel.com/docs/9.x/scout#configuring-filterable-data-for-meilisearch have you see this?

  • 0
Lee

filterableAttributes

Done it

Undefined array key "facets"

Still the same so you must have installed somethig that works

  • 0
altrano

in config/scout is already an example to fill out.

  • 0
Lee

Ive read that webpage and followed the instructions

php artisan scout:sync-index-settings

No index settings found for the "meilisearch" engine.

Thats the error

  • 0
altrano

index-settings instead oh just settings?

  • 0
altrano

hmm... seems i can't help you, so sorry, i have tried.

  • 0
Lee

Right Ive read it updated it found the product index and gone through that with a fine tooth comb

Flushed the products reimported the products rest and updated them, in post man

It found the index

Still the same error

Undefined array key "facets"

Also I have 9 products in the category and with all that done it still shows 6

You musty have done something to get it working

  • 0
Lee

Ive got it working

  • 0
altrano

'filters' => $search['facetDistribution'], not "'filters' => $search['facets']," right? i have just seen it.

  • 0
Lee

No thats got nothing to with it

This line

1$options['filter'] = 'category_ids = ' . $this->category->id;

Alex refactors it to this

1$products = $this->category->products->find(collect($search['hits'])->pluck('id'));

And deletes the first line

Wrong

As soon as I left

1$options['filter'] = 'category_ids = ' . $this->category->id;

That line in worked liked a charm

$search = Product::search('', function ($meilisearch, string $query, array $options) {

1 $filters = collect($this->queryFilters)->filter(fn($filter) => !empty($filter))
2 ->recursive()
3 ->map(function ($value, $key) {
4
5 return $value->map(fn ($value) => $key . ' = "' . $value . '"');
6
7 })
8 ->flatten()
9 ->join(' OR ');
10 $options['filter'] = null;
11
12 $options['filter'] = 'category_ids = ' . $this->category->id;
13
14 $options['facetsDistribution'] = ['colour', 'size', 'fragrance', 'theme'];
15
16
17 if($filters)
18 {
19
20 $options['filter'] = $filters;
21
22 }
23
24 if($this->priceRange['max'])
25 {
26 $options['filter'] .= (isset($options['filter']) ? ' AND ' : '') . 'price < ' . $this->priceRange['max'];
27 }
28
29 return $meilisearch->search($query, $options);
30
31})->raw();
32
33
34$maxPrice = $this->category->products->max('price');
35
36
37$products = $this->category->products->find(collect($search['hits'])->pluck('id'));
  • 0
Ihor

Hi. Help my ))) Lesson #33

Attribute category_ids is not filterable. This index does not have configured filterable attributes. 1:13 category_ids = 2 (View: C:\xampp\htdocs\app-shop\resources\views\categories\show.blade.php)

  • 0
Bilal

You need to make this field filterable!

First of all, add it to the "toSerachableArray()" function as follows:

public function toSearchableArray(): array { return array_merge( [ // ...

1 'category_ids' => $this->categories->pluck('id'),
2
3 ],
4 // ...
5 );
6}

Then it would help if you let Meilisearch know that this field is searchable. You can use the Postman Meiliearch collection, as Alex shows in the video. Another way of doing it, which is the way I did is by creating a new command that will add any field to Meilisearch.

Good luck,

  • 0
Ihor

Thank you very much!

  • 0
Bilal

Hi community, I am struggling with the price filter.

1
2$maxPrice = $category->products->max(fn ($product) => $product->price->getAmount());
3$price = $request->get('price') ?? $maxPrice;
4
5 $search = Product::search(
6 query: trim($request->get('search')) ?? '',
7 callback: function (Indexes $meilisearch, string $query, array $options) use ($category, $filters, $price) {
8 $options['filter'] = 'category_ids = ' . $category->id;
9
10 if ($filters)
11 {
12 $options['filter'] .= ' AND ' . $filters;
13 }
14
15 $options['filter'] .= ' AND price <= ' . $price;
16
17 $options['facets'] = ['size', 'color'];
18
19 return $meilisearch->search($query, $options);
20 },
21 )

The price filter here is not working. I've been reading about an issue with Laravel Scout/Meilisearch that integers are considered strings; hence, the '<=' never works. None of the products is returned.

I even tried to add a where() clause on the Product::search() before calling get(). This returns all products ignoring the price filter.

->where('price <=', $price)

I appreciate your feedback.

Thanks Bilal

  • 0
Bilal

My bad,

Inside the toSearchableArray() function, since I am using Price as Money:

public function toSearchableArray(): array { return array_merge( [ 'id' => $this->id, 'title' => $this->title, 'slug' => $this->slug, 'description' => $this->description, 'price' => intVal($this->price->getAmount()), 'category_ids' => $this->categories->pluck('id'), ], $this->variations->groupBy('type') ->mapWithKeys(fn ($variations, $key) => [ $key => $variations->pluck('title')]) ->toArray(), ); }

$this->price->getAmount() returns a string. Now I cast to integer; everything works well.

In case someone faces the same issue in the future :-)

  • 0
Lee

Facets distribution problem solved

Version 25 is still available

OPEN YOUR TERMINAL

git clone https://github.com/meilisearch/meilisearch cd meilisearch

On documentation this will install the latest version which is 30

git checkout latest

DO NOT INSTALL THIS

INSTALLL THIS VERSION

git checkout V0.25

Update the rust toolchain to the latest version

rustup update

Compile the project

cargo build --release

Execute the server binary

./target/release/meilisearch

To run this in production on ubuntu

https://lindevs.com/install-meilisearch-on-ubuntu

THE LINK FOR UBUNTU

sudo wget -qO /usr/local/bin/meilisearch https://github.com/meilisearch/meilisearch/releases/v0.25.0/download/meilisearch-linux-amd64

Please note installing Version 30 until alec updates the course to show us about the facet distribution will not work on version 30

You will also need to update your Compser.json file for the meilisearch.php to version 23

https://github.com/meilisearch/meilisearch-php/releases/tag/v0.23.0

Hope that heps everyone

  • 2
Lee

Any ideas guys

Json deserialize error: unknown field facetsDistribution, expected one of q, offset, limit, page, hitsPerPage, attributesToRetrieve, attributesToCrop, cropLength, attributesToHighlight, showMatchesPosition, filter, sort, facets, highlightPreTag, highlightPostTag, cropMarker, matchingStrategy at line 1 column 28

Using Meilisearch v0.30.0

Version v.0.25.0 used in the video is not longer available

  • 0
Miroslav

Hi Alex,

I would like to ask, why the payment intent is attached to the cart and after successful payment that the cart is deleted and the order is created. This way we know that the order is paid because we create it after successful payment, but we have lost the payment intent relation. Maybe we can preserve converted carts and link it the with corresponding order or we can create order payments table, where we can add all order payments.

Hope you are well and continue this course as it is in Development for quite a long time.

  • 0
Miroslav

Hi Alex,

Could you please provide a better way of getting cart variation stocks amount different from $variation->stocks->sum('amount') as stocks relation will grow with orders and refills

Also why would you prefer Laravel collection methods instead of normal foreach in syncAvailableQuantities for building $syncedQuantities as this calls a lot of methods and callbacks instead of 1 native loop?

Thank you for time and outstanding work!

  • 0
Miroslav

Hi, on constrained columns index is added automatically, but parent_id does not have a foreign key or index on products and variations tables, is that intentional?

  • 0
Pirvan

Hello, no download project files link ?

  • 0
Ibrahim

hi, what is the database client software used ?

  • 0
Nickolaj

Sequel Pro

  • 0
Ričards

TablePlus

  • 0
Theophilus

Hi folks. I struggled with this error "Json deserialize error: unknown field facetsDistribution, expected one of q, offset, ...". Unknown to me, there had been a breaking change for the search endpoint. "facetsDistribution" search parameter has now been renamed "facets". https://github.com/meilisearch/MeiliSearch/releases. Thought that may help someone save some hours. I found it the hard way.

  • 5
Elliot

Thanks mate.

  • 0
Lee

Undefined array key "facets"

Thats what get using facets

$search = Product::search('', function ($meilisearch, string $query, array $options) {

1 $options['facets'] = ['colour', 'fragrance'];
2 return $meilisearch->search($query, $options);
3
4})
5->raw();
6
7
8$products = $this->category->products->find(collect($search['hits'])->pluck('id'));
9
10
11
12return view('livewire.product-browser', [
13 'currencies' => $currencies,
14 'products' => $products,
15 'filters' => $search['facets']
16]);
  • 0
Oscar

I dont understand stucked again video 36. Import to postman from where?

  • 0
Harish

Import from here: https://docs.meilisearch.com/learn/cookbooks/postman_collection.html#import-the-collection

  • 0
Marek

Hi Alex. Excellent course. But I found a small flaw in EP39. The max price filter does not accept a different subvariant price (different price per color/size variant). Can you fix it? Thank you!

  • 2
Oscar

The link of the image is for me: http://localhost/storage/2/nike.jpeg But the image does not appear in browser if I enter this link, how does it work? Thanks

  • 0
Nickolaj

Did you remember to link the storage folder? php artisan storage:link

  • 0
Lori

hello please can anyone help i get a mysql error use the laravel adjacency helper tree()->get()->toTree() i've search for a solution online but nothing

  • 0
Oscar

Add HasRecursiveRelationships to Category Model...

  • 0
Reza

Where can I find all the coding? I am jumping between sections to learn what I need.

  • 2
Warren

any suggestions on how to build up $queryFilters in situations where your "variations" are in sepperate tables (color in one table, size in another)?

  • 0
Lykourgos

What is the key shortcut for VS Code for adding the namespace on top of the classes?

  • 0
Lee

Use the PHP Namespace Resolver extension and then click the class name and press Ctrl + Alt + I (i) on Windows

  • 0
Daniel

When we created the image gallery it was mentioned that we could present the images of the variations. How can I do this? I tried in many ways and I couldn't.

I tried: $this->product->variations->getMedia();

But it always gives an error that the collection does not exist or the method does not exist. How can I get the images of the variations? Because I'm interested in having an image of the product and the variations

  • 0
Matt

Hi All. Alex please he could show us you how to do pagination on products because when there are a lot of products it can be a lot with ram memory. THX PS: It is about filtering products and displaying in categories.

  • 0
Chris

Is this course now finished? I have enjoyed the content so far but if this is the end I am bitterly disappointed, I don't know if it's just me but I expected a lot more and think this is nowhere near complete yes it matches the demo on the first video but I just assumed that was a teaser and there was more behind the scenes, are we expected to always enter data directly into the database and manually upload product images via the command line, I expected that these things would at least be included in some sort of admin panel. There is also a lot of messy code were Alex says we'll come back to that later... we'll fix it we'll just do it like that for now... then never returns to it again? It still says under development but I have been following for over a week now with no new content.

  • 7
Janroe

ive tweaked a few things and deployed the app

https://online-shoe-store.herokuapp.com/

this course is a very good reference for making a portfolio project and i hope Alex will continue updating this course

  • 0
Alex

Hi Chris! Because admin panels are essentially a course in themselves, I never intended to include one here. Understand that it’s pretty annoying having to do this via the database and command line but Nova would work great for this if you have it.

With the bits to fix up and refactor, I completely agree and I have a big list based on feedback which I’ll be adding. If you need anything specific feel free to get in touch and I’d be happy to help!

Appreciate your comments :)

  • 0
Lee

I told you it was not finished alex didnt I also Alex you eith need to do a course on translations with laravel loclaistion now t here are some good ones on youtube for the route thats easy but wen it comes to this translation on the models not one perosn on you tube can do it and github have manamras package but understanding it you need to be einstien so som thats soehing for you too look at bindin maodels into trnslations a for an admin anel for the gentle man Nova costs money Laravel Voyager does not and if Alex does not wnat to do a tutroial on voayager thers plenty on you tube easy ones aslo Alex the single product needs doing and if you can shipping syesp ie royal wail with weights eect because in the modern retaill market onlie shops must dispaly the wieehgt sihpping sit and the rpice

  • 0
Ahmed Mahmoud

How are you? Why files attached with videos when I toggle removed from the site

  • 1
Ahmed Mahmoud

please reply

  • 0
Ahmed Mahmoud

why files attached with videos are hidden from videos?

  • 1
Chris

Great course! I have just noticed that the subtotal is getting sent through to the orders page which does not include shipping. Should I change the subtotal column in the orders table to total or add an extra column and include both? Then to get the total should I use getTotalProperty() or create a total() method in either App\Cart\Cart.php or App\Models\Order.php?

  • 0
Lee

Sorted it it was me trying to cut conrers thinking I didnt need to to something I did I didnt fill i something maughty

  • 0
Lee

Anyone come across this

Illuminate\Database\Eloquent\Builder::firstOrCreate(): Argument #1 ($attributes) must be of type array, App\Models\ShippingAddress given, called in /var/www/vhosts/leeweaver.uk/app/Http/Livewire/Checkout.php on line 112

  • 0
Lee

Alex, do you have the completed code on Github or anything please...I need to look at something and why me version isn't working.

  • 5
Lee

Alex how are you putting them categories in a dropdown menu

  • 0
Ilias

Really nice course so far(@part 30). I am enjoying it, just wondering if this application architecture can cover simple products also(for example a product as it is without any variations at all) along with the variable products without poorly "patching" it (for example fake variations). Maybe I am wrong but as it stands I think it will need a good revamp to be able to handle simple type products. I d love to hear your thoughts about it guys.

  • 0
Lee

I tried it on the variations with the Sku variant on the products model and it doesnt work keeps saying foreach must be type of array string given when trying bring the product down so its looking for an array of products which would not be an array on the products table I keep asking Alex to show ius everyone is hes not answering

  • 0
Ilias

We could try to use a fake variation for the simple products and exclude it from filters, etc. but that is exactly what i am trying to avoid. I guess the whole product logic(components, models and cart) need a revamp to be able to use simple products without variations.

  • 0
Lee

I tried it wont work because the the variations not only works with an array it also needs a parent_id for the adjency list and that whould have to be in the products table which again takes in back to to a dropdown so you would need a new model and redirect if the product is sign le product with a a count

  • 0
Lee

I think i figured it if it works

@if($variations->count() < 2) Add To Cart @else
{{ Str::title($variations->first()?->type) }}
@foreach($variations as $variation) @endforeach
@endif product-dropdown
  • 0
Lee
@if($variations->count() < 2) Add To Cart @else
{{ Str::title($variations->first()?->type) }}
@foreach($variations as $variation) @endforeach
@endif
  • 0
Lee

Anyone come across this error

Illuminate\Database\Eloquent\Builder::firstOrCreate(): Argument #1 ($attributes) must be of type array, App\Models\ShippingAddress given, called in C:\wamp64\www\leeweaver\app\Http\Livewire\Checkout.php on line 118

($this->shippingAddress = $this->shippingAddress->firstOrCreate($this->shippingForm)) ?->user() ->associate(auth()->user()) ->save();

  • 0
Lee

Alex A little information for you

Stripe is very strict on what they allow to to be sold.

I sell spiritual products and when to Stripe and had it working a customer paid for a spiritual product and we had o give the money back and the customer was furious because Stripe said they dont allow any Spiritual services entertainment services like netflix because there to high risk Working through Pay Pal have never had problems at all

Also Im working on Ubuntu 20:14 and after uploading the files we have the same problem

Invalid facet distribution, the fields box, size are not set as filterable.

Now doing this on local host it works hw do we get this working update the facets in product whats the script please and can you please do a video on hooking pay pal up to this Im using a the moment Ominpay with Paypal sdk

  • 0
Cyrille Thibaut

Hi, I have this error: Invalid facet distribution, the fields color, size are not set as filterable. yet I followed the tutorial to the letter. I don't understand where the error comes from

  • 0
Selorm

you need to add the attributes to the list of attributes that can be used for filtering on meilisearch

the easiest solutions to do this

1$client = app(Client::class);
2$client->index('products')
3->updateFilterableAttributes(['color', 'size'])

once before the search to update the index on meilisearch

  • 0
Cyrille Thibaut

Thanks, that's exactly what I did! , I created a ScoutServiceProvider, and I put the code you indicated

  • 0
Lee

Matey it worked in production thankyou Alex you should have should us that lol make sure import the meilisearch client tho and add the service provider to config/app

  • 0
Phạm

Hi I can't find tree method in staudenmeir/laravel-adjacency-list package. It seems missing

  • 0
krekas

maybe because you didn't search? https://github.com/staudenmeir/laravel-adjacency-list#trees

  • 0
Selorm

Does anyone know why I keep getting Attribute `price` is not filterable. Available filterable attributes are: ``. 1:6 price = 45500 when a closure is passed with a filter option.

Product's toSearchable

1public function toSearchableArray(): array
2 {
3 return [
4 'id' => $this->id,
5 'title' => $this->title,
6 'slug' => $this->slug,
7 'price' => $this->price,
8 'description' => $this->description,
9 'category_ids' => $this->load('categories')->categories->pluck('id')->toArray(),
10 'image' => $this->getFirstMediaUrl(),
11 ];
12 }

The related search

1Product::search('', function (Indexes $meilisearch, string $query, array $options) {
2 $options['filter'] = 'price = 45500';
3 return $meilisearch->search($query,$options);
4})->get();

Thanks.

  • 0
Lee

You have to use Postman and import the meilisearch into postman and goto to update the filterable attributes Alex shows you from Episode 31 onwards but from your doing $options['filter'] = 'price = 45500'; no its just 'price' but the problem is if your like me ad postman wont update the filterable attributes you got a problem Alex some where in the videos shows how to do it without post man but Ive not seen that yet hope that helps

  • 0
Lee

https://docs.meilisearch.com/learn/cookbooks/postman_collection.html#edit-the-configuration thats the link

  • 0
Selorm

The list of attributes that can be used for filtering in Meilisearch is null by default, to get around it,

add all your settings inside config/scout.php

1'meilisearch' => [
2 'host' => env('MEILISEARCH_HOST', 'http://localhost:7700'),
3 'key' => env('MEILISEARCH_KEY', null),
4 'settings' => [
5 \App\Models\Product::class => [
6 'updateFilterableAttributes'=> ['director','genres',],
7 'updateStopWords' => ['the','a','an'],
8
9 ],
10 ],
11],

and in the register method of the AppServiceProvider sync the settings with meilisearch. You can put it in separate service provider if you want

1public function register()
2 {
3 if (class_exists(MeiliSearch::class)) {
4 $client = app(Client::class);
5 $config = config('scout.meilisearch.settings');
6 collect($config)
7 ->each(function ($settings, $class) use ($client) {
8 $model = new $class;
9 $index = $client->index($model->searchableAs());
10 collect($settings)
11 ->each(function ($params, $method) use ($index) {
12 $index->{$method}($params);
13 });
14
15 });
16 }
17
18 }

you can also put into an artisan command

  • 0
Angel

Hey Selorm, adding that service provider do you need to use postman in order to make the update in meilishearch?

  • 0
Lee

N you dont as long you add the values in the e service provider it will work just make sure your flush and import to "app\Models\Product" to update

  • 0
Angel

Lee, thank you so much mate!!

  • 0
Theophilus

Selorm, thanks in Petabytes for your most valuable solution. You have ended 2 days of frustrating search for solution to the 'unfilterable' error. I appreciate.

  • 0
Lee

Right Meilisearch is picking up the variation indexes

public function toSearchableArray() { return array_merge([

1 'id' => $this->id,
2 'title' => $this->title,
3 'slug' => $this->slug,
4 'price' => $this->price,
5 'category_ids' => $this->categories->pluck('id')->toArray(),
6 ],
7
8 $this->variations->groupBy('type')
9
10 ->mapWithKeys(fn ($variation, $key) => [
11
12 $key = $variation->pluck('title')
13 ])
14
15 ->toArray()
16);

Dispaying variation not the title

0

array ID 3 TITLE 10 ml Lavender Oil SLUG 10ml-lavender-essential-oil PRICE 3.49 CATEGORY_IDS

array

Trying update in post man { "filterableAttributes": ["size", "category_ids"] }

This is all i get

{ "uid": 61, "indexUid": "products", "status": "enqueued", "type": "settingsUpdate", "enqueuedAt": "2022-03-31T18:57:16.6859462Z" }

Any suggesitions

  • 0
Phạm

Hi Alex, This package staudenmeir/laravel-adjacency-list doesn't seem to work anymore. I got tree notice "method tree() not found".

  • 0
Selorm

You need to add

1use HasRecursiveRelationships;

to your model. ie Category or Variation

  • 0
Phạm

Hi Selorn I added it but it didn't work. You can check it on this link https://github.com/tuanphamxtasea/E-commerce/issues/1 Code in master branch

  • 0
Phạm

Hi Selorm, Do you have git repository ? I think I missing something. I want to compare with your code. Thanks

  • 0
Phạm

Fixed. I need to set parent_id to null in database

  • 0
Lee

After looking at this problem Undefined array key "facetsDistribution" it seems that you habe to change the the facet attributes in post man and update them after do that ad following Alex still Undefined array key "facetsDistribution"

  • 0
Phạm

I got tree notice "method tree() not found". Why is that ?

  • 0
Khalil

you need to add "use HasRecursiveRelationships;" to your model "Category or Variation"

  • 0
Phạm

I have already added it. The result like it "[]". Still them same Khalil

  • 0
Khalil

make sure tree() at beginning at the root

like : Category::tree()->get()->toTree();

not like: Category::anythingelse()->tree()->get()->toTree();

if its already at the root and not working can you share your code on github or somewhere else to take a look at it

  • 0
Phạm

Here is the issue I meet, You can check it on this link https://github.com/tuanphamxtasea/E-commerce/issues/1 Code in master branch

  • 0
Phạm

Fixed. I need to set parent_id to null in database

  • 0
Lee

A little information for you Centos 7 is not compatible with mealisearch only Centos 8 and if your using a Plesk Obsiddian thats not compatible wtth Centos 8 the only one for mealisearrch you can use is Ubuntu 20.04

  • 0
Lee

Notifications was working on Alpine Js when adding the x-cloak and following he instuctions now not working

  • 0
Prasad

Updating item quantity it showing the quantity as one alex please help me on it

  • 0
Rezaul Hoque

as an ecommerce app, this course should have image upload with file ponds. I understand we can do it, but rushing the course wont help us

  • 0
Selorm

Alex a quick one about the way Categories in EP 3 is setup using parent_id on the same table with slug being unique

How will a category structure of Brands having Nike as a child, same Nike will be a child of Men, women, kids, and accessories category, Adidas will have similar structure likewise all brands

1BRANDS
2 NIKE ADIDAS
3 MEN MEN
4 WOMEN WOMEN
5 KIDS KIDS
6 ACCESSORIES ACCESSORIES

Clothing will also have Men, Women, kids as children, since slug is unique these items can't be duplicated. How will these issues be solved using the same structure demonstrated in Ep 3?

  • 0
Angel

I think that maybe you can combine the slug from the parent category and the new category. Something like: nike-men, adidas-men

  • 0
Khalil

Ep. 28 , when removing the second item in cart , cart component get refreshed but with wrong item due to lack of key

in Ep <livewire:cart-item :variation="$variation"/>

it should be <livewire:cart-item :variation="$variation" :key="$variation->id"/>

update: sorry i just noticed its fixed in EP 29

  • 2
Yoosam

You helped me. Thanks.

  • 0
Prasad

http://laravel-ecommerce.test/storage/2/air-force-1-white.jpeg this URL is not showing image but URL is correct but while loading in another browser its not showing image

  • 0
Angel

Hey Alex, can you please make a video about facetsDistribution? Right now we only have this:

1$options['facetsDistribution'] = ['size', 'color'];

But i think is important how to add this dynamically.

Hope this makes sense to you.

  • 3
Lee

After looking at this problem Undefined array key "facetsDistribution" it seems that you habe to change the the facet attributes in post man and update them after do that ad following Alex still Undefined array key "facetsDistribution"

  • 0
Daniel

Now another question!! But now Livewire and image upload.

I'm applying what I'm learning in the course in a test e-commerce for the company I work for.

But I have the need that when the user chooses the product, he has to upload an image and I need to associate this image with the shopping cart and the order.

The upload itself, I'm already doing it and it falls into a temporary folder and saved in a temporary table to only later associate it with the user/cart/order.

But I can't find the best way to make this association. And I would like to use the media gallery as we use for product images.

  • 2
Daniel

Let's talk about Meilisearch!

It was very interesting and constructive to know how Meilisearch works to index products to speed up searches.

But let's suppose that we have an e-commerce administrative area and that we can add new products and variations, how can we make sure that meilisearch is always updated with the table of products and product variants that we have?

is it possible to do this directly from Laravel (PHP) or would we have to do a cronjob that every x time would update the meilisearch?

What would be the best way to get around this situation?

  • 2
Rezaul Hoque

Have a look at their documentation. When you deploy the project there is the serve which will automatically run the commands everytime a record is added to the index.

  • 0
Daniel

Good to know, can you share the documentation link where you have this information?

  • 0
Rezaul Hoque

https://docs.meilisearch.com/learn/cookbooks/running_production.html

  • 0
Lee

Meilisearch wont work on centos 7 any suggestions

  • 0
Daniel

I using on Ubuntu 20.04 and owrks fine. Both in production (Digital Ocean) and on the development server (Office).

  • 0
Lee

Ubuntu 20.04 works centos 7 does not work with meilisearch and if you have plesk obsidian centos 8 works with meilisearch but plesk is not upgrading to centos 8 so thats not oing to work you neeed to latest ubuntu

  • 0
Lee

Undefined array key "facetsDistribution" Im trying to run meilisearch iin postman not a chance wont bring it up

  • 0
Rezaul Hoque

Not too sure about that mate. You can create an issue in the official GitHub repository

  • 0
Akshoy

Hi Alex the source code is bit confusing, are you preparing it like other series ?

  • 1
Rezaul Hoque

can we also ask for realtime order updates and notifications on changes with orders within the website (not email), please. I know we can do $emit event but its not gonna do broadcasting. Doing that will fulfill the lack and take this project to next level!

I am waiting to hear back from you!

  • 0
krekas

Use wire:poll for that

  • 0
Rezaul Hoque

This is not recommended as it makes too many Ajax requests. Conventional method is use to use event etc

  • 0
Rezaul Hoque

I strongly recommend you introduce 3d secure payment with livewire without cashier using only stripe-php library. Most of the banks in europe these days only accepts 3d secure payments.

  • 2
Chris

Alex, any reason you stopped putting the source with the courses?

  • 9
Marcel

Did you guys got an update on source codes ?

  • 0
Maiko

Following, I want to see the source code also

  • 0
JD

Suggestion: When saving the order details like subtotal, you should also be storing the "current" price of the variation that is ordered. Reason is when displaying back the orders, you're displaying the price for the variation as it currently is in the products table, but that price may have changed since the order was placed. If that happens the price show for the order won't match up to the prices of the variation.

Also, you should be storing the shipping rate that was applied to the order. Same scenario applies here as my paragraph above. I'm sure you're getting my point. Basically any price that was used during an order should be stored for future reference so that it is accurate to that actual order and not current pricing.

  • 3
Chris

On episode 22 (Adding items to cart) I get a strange 500 error when using this code block to update the existing item quantity.

This this is the block in question:

1public function add(Variation $variation, $quantity = 1)
2{
3 if ($existingVariation = $this->getVariation($variation)) {
4 $quantity += $existingVariation->pivot->quantity;
5 }
6 $this->instance()->variations()->syncWithoutDetaching([
7 $variation->id => [
8 'quantity' => min($quantity, $variation->stockCount()),
9 ],
10 ]);
11}

If I remove the IF Statement I can add 1 product, but if the IF Statement is there I get the livewire 500 error.

On the Network DevTools it say it's coming from the product-selector | Status 500 | Type: fetch

There is No Stacktrace or error. Only a blank black modal pops up.

  • 0
Alex

Are you definitely using ->withPivot('quantity') on the Cart variations relationship? Another thing to check would be the getVariation method, if you could post it here.

  • 0
Chris

Okay was definitely a Php error: found in the log Out of memory (allocated 23471325184) (tried to allocate 262144 bytes) Cart\Cart.php on line 65:

1protected function instance()
2{
3 if ($this->instance) {
4 return $this->instance();
5 }
6 return $this->instance = \App\Models\Cart::whereUuid($this->session->get(config('cart.session.key')))->first();
7}

Got caught in a infinite loop in the If statement. was returning the this->instance() method rather only the $this->instance.

This fixed all the problems. =)

1 protected function instance()
2 {
3 if ($this->instance) {
4 return $this->instance;
5 }
6...
  • 0
Angel

Hey Alex, the order confirmation template is missing from the download section.

  • 1
Daniel

Hi Angel, You can use the dashboard page as a template and make some changes.

  • 0
Gavin

Alex, I've noticed that when you type the curly braces you go back after adding one, to add the second. Isn't your vscode set up to just hit '{{' and then it completes the tags for you?

  • 1
Johan

Hi, Alex WDYT? about use a view sum stocks and subtract the orders quantity, and after just make a join ?

  • 0
Sanzhar

Hi, anybody know how to implement 15% discount for first order if user registered?

  • 0
Angel

Hi, I think that you need to check if is the first order for your user then, apply that discount.

  • 0
Angel

Hey Alex, the checkout template is missing from download list.

  • 2
Omar

Here is the code , in case you or someone else needs it.

1<a
2 href="/cart"
3 class="flex items-center text-sm font-medium text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-300 transition duration-150 ease-in-out">
4 Cart (0)
5</a>
  • 0
Angel

Thanks but no, I'm not talking about that piece of code.

  • 0
Janroe

Hi Alex, a checkout template would be very helpful

  • 0
Alex

Sorry folks, it's just been added now 👍

  • 0
Janroe

nice, thanks!

  • 0
Bojan

Thanks

  • 0
Sanzhar

Ep. 48 - logged user save address perfectly, but if quest save address I get this error:

Call to undefined relationship [] on model [App\Models\ShippingAddress].

1($this->shippingAddress = ShippingAddress::whereBelongsTo(auth()->user())->firstOrCreate($this->shippingForm))
2
3 ?->user()
4
5 ->associate(auth()->user())
6
7 ->save();

Anybody face to this issue?

  • 0
Alex

This will be fixed over the next few episodes when we get to creating the order 👍

  • 0
Lee

Alex your in trouble ive just seen that ive been thinking it was me naughty lol

  • 0
Murfy

what's the app you are using for Postgres? not seen that one before.

  • 0
Alex

Postico

  • 0
arjan

Hello, when creating a new category with new products and variations such as:

Category: Coffee Machines product: luxury espresso machine. variation: fresh milk container

The "coffee machines" category page also lists the variations of other products as filters.. a size 9 rainbow colored coffee machine would be nice, but it doesn't really make sense. did I miss something about this in the episodes? I think it has something to do with [facetsDistribution]?

  • 0
Gavin

Product variations basically as trees, is this a common way of doing this? It kinda makes sense but I have not seen it done like this while reviewing ecommerce solutions.

Also, I'm curious to see how that would work in an admin UI/UX wise. Everything is done now directly on the database, but that is not real life. Are you planning to do (some) admin functionality too?

  • 0
John

Am getting this error on the ProductBrowser,

Attribute category_ids is not filterable. Available filterable attributes are: ``. 1:13 category_ids=4

Am using meilisearch v0.25.2

please asist

  • 2
Janroe
  • this is addressed in episode 36 at 4:00 timestamp using postman
  • in the meantime, what i did was not pass the $options in $meilisearch->search() until the fix in episode 36 like so,
1$search = Product::search('', function ($meilisearch, string $query, array $options) {
2 $options['filter'] = 'category_ids = ' . $this->category->id;
3
4 return $meilisearch->search($query); // dont pass $options
5})->get();
  • 0
John

Thanks mate

  • 0
Oscar

Thank you so much!

  • 0
Sanzhar

Hi Alex, what about 'min' price? When less than min price - all filters disappear. Ep 39 Filtering by price.

  • 1
Francis

ep 29: orderByPivot('id') should be used instead

  • 0
Daniel

Hey Alex, I have a problem in class 38.

Error: Call to a member function map() on null (View: /home/ddrummond/Projects/e-commerce/resources/views/categories/show.blade.php)

in this line: ->map(function ($value, $key) { return $value->map(fn ($value) => $key . ' = "' . $value . '" AND'); })

But my code is the same as yours, I've reviewed everything and I'm not finding the problem

  • 1
Marwan

I have the same problem as yours, did you solve it?

Accualy I solve it and the problem was the return

1Collection::macro('recursive', function () {
2 return $this->map(function ($value) {
3 if (is_array($value) || is_object($value)) {
4 return collect($value)->recursive();
5 }
6 return $value;
7 });
8 });

Add return before ->map.

  • 0
Ričards

Hey Alex, when selecting both colors e.g., white and black shouldn't there be both shoes visible?

  • 0
Alex

That would probably be better, yes! Just adjust the Meilisearch query to use OR instead of AND.

  • 0
Deep Inder

Unable to Fetch and show $skuVariant result when selecting color and size. Also no result if using DD on skuVariant. Stuck here on 3:38min on 10. Faking adding the final variation video. Can anyone help me on how to solve this. Thanks.

  • 0
Alex

Hey Deep. Could you put the relevant code in a GitHub Gist and I'll take a look?

  • 0
Angel

Hey Alex, thanks for this course. I was playing around with this and notice that if you have one product in the "New in" category only with one color variation and size this shows the others. Is normal this behaviour? I mean, I think that the live wire component must show the variations related to the product that list.

So, if you select the variation "rainbow" this clear the other 2 variations and if you revert that selection all the variations shows up.

  • 1
Alex

Thanks, I'll check this out and adjust the course with a fix.

  • 0
JD

Alex, if you haven't already planned on this suggestion I would like to see the browser query string updated with the searched filters so that when you click on a product and then hit the back button, the browser will bring you back to the same search filters. This concept is very important and logical in these kinds of searches.

  • 1
Alex

Thanks for the suggestion. This should be pretty easy to achieve because Livewire has native support for this. I'll schedule in an episode to cover it 👍

  • 0
Thomas

Hi, when you use cknow/laravel-money like that, how do you handle price inputs in backoffice? Any advices?

  • 0
Omar

One method of achieving that is to use a Mutator (setter) in your model (in this case Product) like below:

1public function setPriceAttribute($value)
2{
3 $this->attributes['price'] = $value * 100;
4}

So if user entered 50 for price, when the model is saving the record, it will multiply the price by 100, and when you show the price in your views it will show the formatted and expected price.

I hope this helps.

  • 0
Daniel

Hi.

After uploading the image, when I call its url, I get 404 as a result. The path is correct and the image is in the folder. Anyone with the same problem, how to solve it?

  • 0
Daniel

I managed to solve the problem, I had not created the symlink

php artisan storage:link

Thanks

  • 0
Alex

Glad you sorted it!

  • 0
Lee

php artisan storage:link it tried it doesnt work still cant get it to load but when loading the asset it works

  • 0
arjan

hi not sure why meilisearch returns a error when i try to add the search query. Laravel returns the following;

Attribute category_ids is not filterable. Available filterable attributes are: ``. 1:13 category_ids = 18

in the meilisearch mini-dashboard the id's are shown as following:

array [ 0:13 1:8 ]

im on laravel 9.0 and meilisearch v0.25.2

hope you can help me out.

  • 3
Marcel

As far as I know Meilisearch got updated and now you need to be explicit on which properties are filterable. Laravel Scout however has no way to define these filterable properties. There are some workarounds, but it requires a bit more work. See the Meilisearch documentation for the updateFilterableAttributes method. I got stuck here as well, will have a look tomorrow if I can find a workaround or if downgrading Meilisearch helps.

  • 0
Marcel

I got it working with Meilisearch v0.25.2 now. Like I said, recent versions of Meilisearch require you to be explicit about what properties can be filtered. However, Laravel Scout doesn't offer this option. By looking at the documentation of Meilisearch, you can use the updateFilterableAttributes() method for that. This method needs to run at runtime, so I created a ScoutServiceProvide for that and added it in the boot method.

$client = app(Client::class); $client->index('products')->updateFilterableAttributes([ 'category_ids' ]);

Now you can use category_ids as a filter in your ProductBrowser livewire component.

  • 0
arjan

Brilliant! Got it sorted, thanks!!

  • 0
Alex

Thanks for addressing this Marcel! A little later on (ep 36, I think), we explicitly set these, so hopefully it won't cause too much confusion.

  • 0
Marcel

Made it to the episode where you use Postman to add these filterable types now, didn't think of that! And although the category_ids are set explicit and you no longer need the serviceprovider for that, you can still use it to add the size and color attributes as well.

  • 0
Cyrille Thibaut

Tks! your solution solved my problem

  • 0
Lee

Alex can you do a courses of Laravel/Paypal for this and include in this course please

  • 1
Manuel

Hi Alex.

It would be nice if you can push the code being each commit a step.

🙂

  • 4
John

AM not sure why my product variation relationship ain't working, I ended up doing this in the selectedVariationModel

return Variation::find($this->selectedVariation)->descendants()->depthFirst()->get();

Also my inline conditional statement aint working too. so I had to remove the "?" in the statement. e.g

From: {{ Str::title($variations->first()?->type) }}

To: {{ Str::title($variations->first()->type) }}

Is there anything am missing in my setup?

I get this error:

syntax error, unexpected '->' (T_OBJECT_OPERATOR) (View: .../resources/views/livewire/product/product-selector.blade.php)

  • 0
Tom

I had the same syntax error and then I upgraded my php to version 8 and its now working

  • 0
Alex

Yep, you'll need > PHP 8 for this course.

  • 0
John

Thanks 🙏

  • 0
arjan

Great Course! i'm getting a 404 when loading the image im using homestead/ vagrant any tips on how to get the image displayed properly ?

  • 0
Alex

Have you run

1php artisan storage:link
  • 0
arjan

Yes i did. but it throws a exception :

ErrorException

symlink(): Protocol error

  • 0
arjan

Got it. had to start vagrant as administrator -.-

  • 0
Alex

Ahh brilliant. Glad it's sorted 👍

  • 0
Sanzhar

Awaiting new episodes!!!!!

  • 1
Hadi

So what if we need to make this cart in api like form mobile app or react app how we can handle the session ?

  • 2
Alex

I won't be covering the API side in this course, but you could use any API authentication method that Laravel supports and then reference the cart UUID in any requests.

  • 0
Hadi

Thank you, so the guest cart in this case will not be in database?

  • 0
Alex

Yep, the guest cart gets stored in the database. When the user authenticates, it's transferred to that authenticated user.

  • 0
alexander

is anybody gettting this error using the Laravel Money package Problem 1 - Root composer.json requires cknow/laravel-money ^1.0 -> satisfiable by cknow/laravel-money[v1.0.0, v1.0.1, v1.0.2, v1.0.3]. - cknow/laravel-money[v1.0.0, ..., v1.0.3] require illuminate/support ~5.1 -> found illuminate/support[v5.1.1, ..., 5.8.x-dev] but these were not loaded, likely because it conflicts with another require.

You can also try re-running composer require with an explicit version constraint, e.g. "composer require cknow/laravel-money:*" to figure out if any version is installable, or "composer require cknow/laravel-money:^2.1" if you know which you need.

  • 0
alexander

I just ended up using the build in money helper form laravel cashier

  • 0
Martin

I have a similar thing when I used Laravel 8, so it worked well. Now I have a similar mistake with Laravel 9.

Problem 1 - Root composer.json requires cknow/laravel-money ^6.2 -> satisfiable by cknow/laravel-money[v6.2.0]. - cknow/laravel-money v6.2.0 requires illuminate/support ^7.0|^8.0 -> found illuminate/support[v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev] but these were not loaded, likely because it conflicts with another require.

  • 0
Martin

Problem solved. I used the "akaunting/laravel-money" package. With Laravel 9 it works great.

  • 0
Warren

Thanks Martin, This suggestion worked for me, with Laravel 9, PHP 8.1.2 inside docker.

  • 0
Martin

The "cknow/laravel-money" package has now been updated. He now supports Laravel 9.

  • 0
Sanzhar

Another cool course. Alex, how to implement if some product not have any variations???

  • 0
Alex

In that case you'd just have to add a single variation for the product. Then, switch around the logic to automatically select the first variation if there's only one. I'll see if I can handle this towards the end of the course 👍

  • 0
Sanzhar

Thank you 👍

  • 0
Lee

Alex how would you do that because I have the same problem changing the logic

  • 0
alexander

Can't wait to get started!. I'm curious do we use Laravel Cashier to handle the payment processing portion??

  • 1
Alex

Yep, we're using Laravel Cashier.

  • 0
Petar

Why not use laravel adjacency list for variations too? It's pretty much the same concept as categories.

  • 0
Alex

That's what we are doing.

  • 0
Marcel

Hi, will you provide the source code ?

  • 0
Seyed Ataii

What SQL client are you using?

  • 0
Alex

Postico (for Postgres)

  • 0
Seyed Ataii

Oof. As a windows user that is a blow to the gut as it's so pretty. Great course btw, enjoying it.

  • 0
Bojan

Really good course!!

  • 0
Ryan

Any new videos today?

  • 2
Haitham

Great work, Alex. This course will help me a lot. Thank you 🙏

  • 2
Joseph

Hi Alex, will this cover any verification at checkout? For example, if two customers are buying the same item with low stock value?

  • 0
Alex

Yes, this is covered! Checks are performed on the cart page and checking out and will flash a message to the user that their cart has changes.

  • 0
Deep Inder

Pretty Amazing course. Will you cover the functionality like deals/sale and discounts, where customers can add coupon codes for certain percentage of discounts later in course?

  • 1
Alex

Not coupons yet, but that's an easy addition later down the line once we're done with the base stuff.

  • 0
Lee

How would you deal with the URLs to make them more SEO friendly? e.g. categories/brands/nike/new-in instead of just /categories/new-in.

  • 2
Alex

Great point Lee, I'll note this down and cover it later on in the course.

  • 0
Umar

This looks amazing, Alex. Will you be making shipping costs dynamic based on destination city or country (i.e. city 1 = $5, city 2 = $10, etc.) ?

  • 0
Alex

Not just yet, perhaps something for later on. Right now, they're just fixed shipping costs.

  • 0
Lee

If you look what alex is doing addnig of the subtotal hes taking this from the variations just add the weight of the product in the variations and do the same thing like this public function weight() { return $this->instance()->variations

1 ->reduce(function ($carry, $variation) {
2
3 return $carry + ($variation->product->weight * $variation->pivot->quantity);
4 });
5}

on App\Cart\Cart then on the shipping types table put al the weights and names of shipping

The Livewire\Checkout

public function mount(CartInterface $cart) { $weight = $cart->weight();

1 $this->shippingTypes = ShippingType::where('weight', '>', $weight)->first()->get();
2
3 $this->shippingTypeId = $this->shippingTypes->first()->id;
4
5 if($user = auth()->user())
6 {
7 $this->accountForm['email'] = $user->email;
8 }
9
10}

The problem ive got itll bring all the relevent shipping tables down that correspond with weight after the weight it has so if the weight is over 2 it wont bring down les than that weight but its bring down weights that are not needed gott a figure that out

  • 0
Lee

Alex buy the way dont whether you know this but Stripe wont accept certain payments you need to add paypal integration to the course

  • 0
Gavin

Awesome Alex! Question though:

Will you be covering displaying/selecting variants with images and/or color options?

  • 0
Alex

Hey Gavin. Did you mean having images attached to each variant (.e.g. when you add White Air Force 1 trainers, it shows a white shoe?). Or did you mean different variations? If it's the latter, you can pretty much add any 'type' of variation you like. It's completely flexible.

  • 0
Gavin

Yes, the first one. That's how for instance Amazon and Zalando do it and would be nice to get an idea of how to implement that. For me it's one of those things I just can't get my head around how to do it.

  • 0
Alex

So, in the course we're going to be attaching images to each variant. The image gallery you see in the demo are just two images attached to products. So, when you add/buy a White Air Force 1, you'll see that image in your cart/orders.

  • 0
Nikita

Hi, how often will new episodes come out?

  • 2
Francis

Daily

  • 0