Return to homepage
23/78. Creating the notification component
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

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.

  • 4
Elliot

Thanks mate.

  • 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

  • 0
Lee
  • 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

  • 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