#130

Опубликовано: 27 Декабрь 2024
на канале: Stack Developers
1,381
29

In Part-130 of Advance E-com series, we will continue working on order placement process. In this video, we will place order and insert order details in orders and orders_products tables.

1) Update checkout.blade.php file :-
First of all, update payment_method to payment_gateway in checkout form.

2) Update checkout function :-
Now we will update checkout function step by step for inserting the order details in orders tables.

2.1) Update payment_method to payment_gateway in if condition to make sure payment_gateway is not empty.

2.2) Add condition to assign COD in payment_method variable if payment_gateway is COD otherwise Prepaid in all other cases like Paypal or any others in future.

2.3) From address id, we will get the delivery details of the user that we want to insert in orders table.

2.4) Finally insert delivery address, coupon, shipping details, grand total, payment method etc. in orders table.

2.5) After inserting orders detail in orders table, get last order id.

2.6) Get user cart items from carts table by comparing with user_id.

2.7) Insert all user cart items in orders_products table in foreach loop.

2.8) Include below header statements at top of ProductsController :-
use App\Order;
use App\OrdersProduct;
use DB;

2.9) Use beginTransaction and commit functions of Laravel to secure the query so that no half query run anytime.

Now check in video; orders details get inserted into orders and orders_products tables.

In next video, we will work on thanks page and will display order details in user account and admin panel.

Join this channel to get complete code:
   / @stackdevelopers