Lestah
364
15
Laravel

how can i decrease stocks base on order quantity

Posted 2 months ago by Lestah

if($data['payment_method']=="COD"){

            //this will get the details of all product inside cart
            $productDetails = DB::table('cart')->where(['user_email' => $user_email])->get();
            //echo "<pre>"; print_r($productDetails); die;
            
    //this part i want to get the product_id and the quantity that was ordered by the user
            
            ProductsAttribute::where('product_id',$product_id)->decrement('stock',$quantity);
            
            return redirect('/thanks');    
        } else {
            return redirect('/paypal');
        }

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.