Answer the question
In order to leave comments, you need to log in
How to make a price change when selecting product properties?
Hello! I'm making an online store and the problem arose to dynamically change the prices of goods. , black ink, 2 - green, blue ink, 3 - white, black ink. I decided to pass all the data needed for this processing:
array:2 [▼
0 => array:3 [▼
"id" => 1
"price" => 15
"options" => array:2 [▼
" color" => "Red"
"capacity" => "30ml"
"id" => 2
"price" => 18
"options" => array:2 [▼
"color" => "Red"
"capacity" => "50ml"
]
]
]
But I don't understand how to process them so that get what I need ((( That is, I need to correctly generate selects .. When choosing a combination, its id will be recorded in a hidden field, which I then need to send to the server .. Please help, I already broke my head!
Answer the question
In order to leave comments, you need to log in
You can add a data attribute to each option in the first select, for example:
<select>
<option value="0" data-color="красная, синяя">Черные</option>
<option value="1" data-color="красная, белая">Красные</option>
</select>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question