plugins – WooCommerce How To Get Second,Third,Fourth… Cart Item Data

global $woocommerce;
$items = $woocommerce->cart->get_cart();
$count = 0;
$gelen = $_POST('Islem');
foreach($items as $item => $cart_item) {
$count++;
if(1== $count){$g1('Islem')=$cart_item('Islem');}
if(2== $count){$g2('Islem')=$cart_item('Islem');}
if(3== $count){$g3('Islem')=$cart_item('Islem');}
if(4== $count){$g4('Islem')=$cart_item('Islem');}
if(5== $count){$g5('Islem')=$cart_item('Islem');}
if(6== $count){$g6('Islem')=$cart_item('Islem');}
if(7== $count){$g7('Islem')=$cart_item('Islem');}
if(8== $count){$g8('Islem')=$cart_item('Islem');}
if(9== $count){$g9('Islem')=$cart_item('Islem');}
if(10== $count){$g10('Islem')=$cart_item('Islem');}
if(11== $count){$g11('Islem')=$cart_item('Islem');}
if(12== $count){$g12('Islem')=$cart_item('Islem');}
if(13== $count){$g13('Islem')=$cart_item('Islem');}
if(14== $count){$g14('Islem')=$cart_item('Islem');}
if(15== $count){$g15('Islem')=$cart_item('Islem');}
if(16== $count){$g16('Islem')=$cart_item('Islem');}
if(17== $count){$g17('Islem')=$cart_item('Islem');}
if(18== $count){$g18('Islem')=$cart_item('Islem');}
if(19== $count){$g19('Islem')=$cart_item('Islem');}
if(20== $count){$g20('Islem')=$cart_item('Islem');}
if(21== $count){$g21('Islem')=$cart_item('Islem');}
if(22== $count){$g22('Islem')=$cart_item('Islem');}
if(23== $count){$g23('Islem')=$cart_item('Islem');}
if(24== $count){$g24('Islem')=$cart_item('Islem');}
if(25== $count){$g25('Islem')=$cart_item('Islem');}
if(26== $count){$g26('Islem')=$cart_item('Islem');}
if(27== $count){$g27('Islem')=$cart_item('Islem');}
if(28== $count){$g28('Islem')=$cart_item('Islem');}
if(29== $count){$g29('Islem')=$cart_item('Islem');}
if(30== $count){$g30('Islem')=$cart_item('Islem');}
}

So, “$cart_item(‘Islem’);” is our cart product’s special text, you can think of this as ID,Product Title or whatever you want.

The problem is $g(number)(‘Islem’) is not getting the (number) product’s “$cart_item(‘Islem’);”


auxiliary resources for you:
https://stackoverflow.com/questions/41039837/get-all-woocommerce-cart-item-names
https://stackoverflow.com/questions/45255375/apply-a-discount-only-on-the-second-cart-item-in-woocommerce
https://stackoverflow.com/questions/28576667/get-cart-item-name-quantity-all-details-woocommerce
https://stackoverflow.com/questions/52281956/get-last-added-to-cart-product-id-in-woocommerce