davidtrushkov / store

A ecommerce store using Laravel 5.2
87 stars 62 forks source link

numeric value out of range #20

Open ubaidillahumar opened 7 years ago

ubaidillahumar commented 7 years ago

when I order the product, I got error :

SQLSTATE[22003]: Numeric value out of range: 1690 BIGINT UNSIGNED value is out of range in '(store.products.product_qty - 1)' (SQL: update products set product_qty = product_qty - 1)

please help me.

davidtrushkov commented 7 years ago

Thats saying the value for row 'product_qty' is out of range. 'product_qty' cant be less than the number 0. There is a row in table where 'product_qty' is less than 0

ubaidillahumar commented 7 years ago

I see when I bought one product the system will decrement all 'product_qty' in table product, not only product in the chart table but all product in table product will decrement, how about this mr? so if there are product in table product value of 'product_qty' = 0 the system will error even through this product not in table cart or not I bought.

On 18 Jul 2017 2:30 a.m., "David Trushkov" notifications@github.com wrote:

Thats saying the value for row 'product_qty' is out of range. 'product_qty' cant be less than the number 0. There is a row in table where 'product_qty' is less than 0

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/davidtrushkov/store/issues/20#issuecomment-315857508, or mute the thread https://github.com/notifications/unsubscribe-auth/AU_KjcJcLFRbkaFlG6Gh1626uF16Ty6Dks5sO7ZygaJpZM4OZeqK .

ubaidillahumar commented 7 years ago

please help me : https://stackoverflow.com/questions/45409487/decrease-product-quantity-in-database-after-checkout/45417588#45417588

davidtrushkov commented 7 years ago

Did that solution solve your problem?

ubaidillahumar commented 7 years ago

yes Mr, thanks you a lot for your great application.

ubaidillahumar commented 7 years ago

was solved after change the code to : foreach ($cart_products as $order_products) { $order->orderItems()->attach($order_products->product_id, array( 'qty' => $order_products->qty, 'price' => $order_products->products->price, 'reduced_price' => $order_products->products->reduced_price, 'total' => $order_products->products->price * $order_products->qty, 'total_reduced' => $order_products->products->reduced_price * $order_products->qty, )); \DB::table('products') ->where('id', '=', $order_products->product_id) ->decrement('product_qty', $order_products->qty); }

ubaidillahumar commented 7 years ago

please help me :

https://stackoverflow.com/questions/45409487/decrease-product-quantity-in-database-after-checkout

On 18 Jul 2017 5:00 a.m., "ubaidillah umar" ubaidillahumar@gmail.com wrote:

I see when I bought one product the system will decrement all 'product_qty' in table product, not only product in the chart table but all product in table product will decrement, how about this mr? so if there are product in table product value of 'product_qty' = 0 the system will error even through this product not in table cart or not I bought.

On 18 Jul 2017 2:30 a.m., "David Trushkov" notifications@github.com wrote:

Thats saying the value for row 'product_qty' is out of range. 'product_qty' cant be less than the number 0. There is a row in table where 'product_qty' is less than 0

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/davidtrushkov/store/issues/20#issuecomment-315857508, or mute the thread https://github.com/notifications/unsubscribe-auth/AU_KjcJcLFRbkaFlG6Gh1626uF16Ty6Dks5sO7ZygaJpZM4OZeqK .