N
N
Nikita2017-05-11 13:16:25
WordPress
Nikita, 2017-05-11 13:16:25

How to get the session ID of a product?

On the "Shopping cart" page, I get the session of the cart items with the request:
$cart = WC()->session->get( 'cart', null );
At the output, I get a list of data for all products in the basket:
array(2) { ["c6ea20f4f2db4fdc4578906a64721348"]=> array(13) {
["is_deposit"]=> bool(true)
["payment_plan"]=> int(1)
[ "product_id"]=> int(10633)
["variation_id"]=> int(0)
["variation"]=> array(0) { }
["quantity"]=> int(1)
["deposit_amount"] => string(1) "0"
["full_amount"]=> int(700)
["line_total"]=> int(0)
["line_tax"]=>
["total"]=> array(1) {
[1]=> float(0)
} ["total"]=> array(1) { [1]=> float(0)
["subtotal"]=> array(1) { [1]=> float(0) } } }
["4706d250811ba7663a8f6f7849a4bfbd"]=> array(13) {
["is_deposit"]=> bool(true)
["payment_plan "]=> int(2)
["product_id"]=> int(9540)
["variation_id"]=> int(0)
["variation"]=> array(0) { }
["quantity"]=> int(1)
["deposit_amount"]=> string(1) "0"
["full_amount"]=> int(500)
["line_total"]=> int(0)
["line_tax"]=> float(0 )
["line_subtotal"]=> int(0)
["line_subtotal_tax"]=> float(0)
["line_tax_data"]=>
}
["subtotal"]=> array(1) { [1]=> float(0) } } }
Question:
How do I get the key (example: ["c6ea20f4f2db4fdc4578906a64721348"]=> array(13) ) of the session specifically for one or another product,
that is, I need to display only its data for each product.
For what?
I need to get one of the product related values ​​and change it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2017-05-11
@Stalker_RED

array_keys()
And you might want to read some more about sessions. Judging by phrases like "sessions related to the product" it seems that you do not quite understand what it is, how it works and why.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question