L
L
LightSid2016-11-18 17:47:22
Yii
LightSid, 2016-11-18 17:47:22

How to check item in session?

There is a product "Box", it may include a different composition and in a different sequence.
It is necessary to recalculate the basket when adding to the basket (session).
If the composition and sequence match, then add the quantity, and if not, then create a new element.
Please tell me how to properly structure the session so that it is more convenient to check.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
entermix, 2016-11-18
@entermix

Store boxes as arrays and then compare:

if ($a === $b){
// коробки идентичны
}

M
Maxim Timofeev, 2016-11-18
@webinar

$session = Yii::$app->session;
$in = $seession->get('some_id');
if($in == $new){
echo 'товары одинаковые';
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question