Y
Y
Yan Aleksandrov2019-05-13 19:20:43
PHP
Yan Aleksandrov, 2019-05-13 19:20:43

How to implement variations?

Good afternoon. I have an array with product variations:

Array
(
    [0] => {"item_id":19,"item_image":"","item_variation":{"steklo":"ударопрочное","material":"металл"},"item_price":"110"}
    [1] => {"item_id":20,"item_image":"","item_variation":{"steklo":"обычное","material":"металл"},"item_price":"130"}
    [2] => {"item_id":21,"item_image":"","item_variation":{"steklo":"ударопрочное","material":"пластик"},"item_price":"150"}
    [3] => {"item_id":22,"item_image":"","item_variation":{"steklo":"ударопрочное","material":"дерево"},"item_price":"160"}
    [4] => {"item_id":23,"item_image":"","item_variation":{"steklo":"обычное","material":"пластик"},"item_price":"175"}
    [5] => {"item_id":24,"item_image":"","item_variation":{"steklo":"обычное","material":"дерево"},"item_price":"199"}
)

I display two blocks of options:
  1. on glass: ordinary, impact-resistant
  2. material: wood, plastic, metal

In this case, we get 6 options.
(in the future, blocks of options, which means there can be much more product variations)
Give an idea how to implement the following at the front:
The buyer first chooses the glass, then the material. Depending on which combination is selected, we get item_id, item_image, item_price.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Shohruh Shaimardonov, 2019-05-13
@joeberetta

You can use Set . It allows you to store unique values.
A good article about sets and what to eat them with

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question