© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
3 replies
smartnathan

Repeater Calculate all quantity fields

Please, how do I get each individual quantity fields as well as the product id.
Essentially, I want to use the product id to get the product product price based on the quantity, then calculate the cost and sum the individual cost of the product and put the sum in the placeholder below.
Solution
I was able to get it solve after looking at the documentation.
Below is my solution.
Forms\Components\Select::make('store_id')
->relationship('store', 'name')                      
->preload()            
->searchable()               
->required(),

Repeater::make('sales_items')->schema([
//The form products select and quantity textinput fields comes in here
])->live()                   
->afterStateUpdated(function (Get $get, Set $set) {
                                $total = 0;
                                $store_id = $get('store_id');
                                foreach ($get('sales_items') as $item) {
                                    $product = StockAvailabilityStatus::where('product_id', $item['product_id'])->where('store_id', $store_id)->first();
                                    if ($product && $item['quantity']) {
                                        $total += $product->bulk_selling_price * $item['quantity'];
                                    }
                                }
                           $set('formatted_total_amount', '₦' . number_format($total, 2));
                            })
Forms\Components\Select::make('store_id')
->relationship('store', 'name')                      
->preload()            
->searchable()               
->required(),

Repeater::make('sales_items')->schema([
//The form products select and quantity textinput fields comes in here
])->live()                   
->afterStateUpdated(function (Get $get, Set $set) {
                                $total = 0;
                                $store_id = $get('store_id');
                                foreach ($get('sales_items') as $item) {
                                    $product = StockAvailabilityStatus::where('product_id', $item['product_id'])->where('store_id', $store_id)->first();
                                    if ($product && $item['quantity']) {
                                        $total += $product->bulk_selling_price * $item['quantity'];
                                    }
                                }
                           $set('formatted_total_amount', '₦' . number_format($total, 2));
                            })
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Calculate Repeater
FilamentFFilament / ❓┊help
3y ago
Testing repeater fields
FilamentFFilament / ❓┊help
3y ago
Dynamic default repeater fields
FilamentFFilament / ❓┊help
16mo ago
dynamic repeater fields names
FilamentFFilament / ❓┊help
17mo ago