'How to show total price of a product based on its variations in react?
I am trying to show the total price of a product based on its selected variants. Like when the user's select the variants from a list, a price will be shown based on that. my variants object is,
choice_options: Array(4)
0:
name: "choice_3"
options: (3) ['2', '54', '67']
title: "imrunvai"
[[Prototype]]: Object
1:
name: "choice_2"
options: (5) ['3543', '3', '453', '45', '345']
title: "sakeefvai"
[[Prototype]]: Object
2:
name: "choice_4"
options: (3) ['345', '45', '4']
title: "sharifvai"
[[Prototype]]: Object
3:
name: "choice_1"
options: (3) ['128gb', ' 256gb', ' 476gb']
title: "Size"
[[Prototype]]: Object
length: 4
[[Prototype]]: Array(0)
This array is totally dynamic. Based on this data I designed frontend like so,
for showing the price based on variants I need to make a variable like,
type: 'first_selected_value-second_selected_value-3rd_selected_value-4th_selected_value-5th_selected_value'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

