See comment in the code:
// Here I want to attach som text to checkout page under order review table for this specifik product id 7498 if quantity is 1
I have in the code bellow tried many things in javascript, but I wanna do It in PHP.
add_action( 'woocommerce_before_cart', 'bbloomer_find_product_in_cart_alt' );
function bbloomer_find_product_in_cart_alt() {
$product_id_7498 = 7498;
$product_id_7475 = 7475;
$quantity1 = 1;
$quantity2 = 2;
$in_cart = false;
foreach( WC()-\>cart-\>get_cart() as $cart_item ) {
$product_in_cart = $cart_item\['product_id'\];
//$quantity_items = $cart_item\['quantity'\];
//$item_quantity += $item-\>get_quantity();
//echo $quantity_items;
//$product_in_cart = $cart_item\['data'\];
//echo $products_in_cart;
//echo $cart_item\['product_id'\] . "\<br\>";
//echo $cart_item\['quantity'\] . "\<br\>";
//echo var_dump($products_in_cart) . "\<br\>";
if ( $product_in_cart === $product_id_7498 ) {
$in_cart = true;
echo "Yes produkt 7498 finns i varukorgen . \<br\>";
$product_quantity_7498 = $cart_item\['quantity'\];
echo "Produkt 7498 / antal: " . $product_quantity_7498 . "\<br\>";
if ($product_quantity_7498 === 1) {
echo "Produkt 7498 antal är 1 . \<br\>";
// Here I want to attach som text to checkout page under order review table for this specifik product id 7498 if quantity is 1
}
if ($product_quantity_7498 === 2) {
echo "Produkt 7498 antal är 2 . \<br\>";
// Here I want to attach som text to checkout page under order review table for this specifik product id 7498 if quantity is 2
}
}
if ( $product_in_cart === $product_id_7475 ) {
$in_cart = true;
echo "Yes produkt 7475 finns i varukorgen . \<br\>";
$product_quantity_7475 = $cart_item\['quantity'\];
echo "Produkt 7475 / antal: " . $product_quantity_7475 . "\<br\>";
}
}
}