Hey guys, on Time: 13:50 to 14:25 on the video. There was a small correction: on decrementQuantity() function as follows: public function decrementQuantity(int $cartId) { $cartData = Cart::where('id',$cartId)->where('user_id', auth()->user()->id)->first(); if($cartData) { if($cartData->quantity > 1){ $cartData->decrement('quantity'); $this->dispatchBrowserEvent('message', [ 'text' => 'Quantity Updated', 'type' => 'success', 'status' => 200 ]); }else{ $this->dispatchBrowserEvent('message', [ 'text' => 'Quantity cannot be less than 1', 'type' => 'success', 'status' => 200 ]); } }else{ $this->dispatchBrowserEvent('message', [ 'text' => 'Something Went Wrong!', 'type' => 'error', 'status' => 404 ]); } }
if i wants to change input value without increment or decrement button but directly from the keyboard typing the quantity amount. how to increment or decrement it by livewire ? Thnks sir
@rafy_works I suggest you that don't give your editable input to your users because it may cause a lot of errors for that you've to do a little but complex_validations, so only go them with just increment/decrement button which will limits quantity as you want... but however if you want to put input via keyboard then comment me, I'll give you that validation code which will stop user to put negative_value and value greater 10 or as you want....
If it reach max quantity then message comes "only 5 quantity available" after if you try to decrement same message comes "only 5 quantity available" instead of decrement. Can you check once?
@@fundaofwebit Thanks for your reply and wonderful tutorials. I added >= now if max quantity is 5 it reach till 6 then message popup that "only 5 quantity available" and then I can't decrement. Even its goes to 0 and negative too.
Hey guys, on Time: 13:50 to 14:25 on the video.
There was a small correction: on decrementQuantity() function as follows:
public function decrementQuantity(int $cartId)
{
$cartData = Cart::where('id',$cartId)->where('user_id', auth()->user()->id)->first();
if($cartData)
{
if($cartData->quantity > 1){
$cartData->decrement('quantity');
$this->dispatchBrowserEvent('message', [
'text' => 'Quantity Updated',
'type' => 'success',
'status' => 200
]);
}else{
$this->dispatchBrowserEvent('message', [
'text' => 'Quantity cannot be less than 1',
'type' => 'success',
'status' => 200
]);
}
}else{
$this->dispatchBrowserEvent('message', [
'text' => 'Something Went Wrong!',
'type' => 'error',
'status' => 404
]);
}
}
if I didn't see this comment , I would tell you about this problem!
Thanks you sir , for your tutorials !
I will wait for more tutorials!
So, for decrementQuantity just to copy this uour code instead of the code from the video?
I already did it myself because I was facing this error after this I see this comment..
otherwise thanks for everything
if i wants to change input value without increment or decrement button but directly from the keyboard typing the quantity amount. how to increment or decrement it by livewire ? Thnks sir
@rafy_works I suggest you that don't give your editable input to your users because it may cause a lot of errors for that you've to do a little but complex_validations, so only go them with just increment/decrement button which will limits quantity as you want...
but however if you want to put input via keyboard then comment me, I'll give you that validation code which will stop user to put negative_value and value greater 10 or as you want....
Hello Sir! If user wants to chenge quantity in input value by keyboard, how to increment or decrement it by livewire?
You might need to use change() or
keyUp() or keyPrees() function on that input field and call that livewire function.
my increment and decrement not working
If it reach max quantity then message comes "only 5 quantity available" after if you try to decrement same message comes "only 5 quantity available" instead of decrement. Can you check once?
Hey,
There was a small correction: on decrementQuantity() functiion as follows:
$cartData = Cart::where('id',$cartId)->where('user_id', auth()->user()->id)->first();
if($cartData)
{
if($cartData->quantity > 1){
$cartData->decrement('quantity');
$this->dispatchBrowserEvent('message', [
'text' => 'Quantity Updated',
'type' => 'success',
'status' => 200
]);
}else{
$this->dispatchBrowserEvent('message', [
'text' => 'Quantity cannot be less than 1',
'type' => 'success',
'status' => 200
]);
}
}else{
$this->dispatchBrowserEvent('message', [
'text' => 'Something Went Wrong!',
'type' => 'error',
'status' => 404
]);
}
@@fundaofwebit Thanks for your reply and wonderful tutorials. I added >= now if max quantity is 5 it reach till 6 then message popup that "only 5 quantity available" and then I can't decrement. Even its goes to 0 and negative too.
@@farmboy4354 please, read back the above comment and don't add >= in incrementQuantity().
keep as it was already as shown in the video.
Interesante hare su proyecto.
Sir try to create ecommerce with codeigniter4
6.48