I want to display the entire shopping cart in a customized way, therefore I have to get access to the:
- Product Image
- Product Title
- Product Price
- Product Attributes
So far I managed to display everything but the attributes. This is my working code so far.
<?php
global $woocommerce;
$items = $woocommerce->cart->get_cart();
foreach($items as $item => $values) {
$_product = wc_get_product( $values['data']->get_id() );
$getProductDetail = wc_get_product( $values['product_id'] );
echo $getProductDetail->get_image();
echo "<b>".$_product->get_title() .'</b> <br> Anzahl: '.$values['quantity'].'<br>';
$price = get_post_meta($values['product_id'] , '_price', true);
echo " Price: ".$price."<br>";
/*attributes*/
/* $available_variations = $_product->get_available_variations();
foreach ($available_variations as $key => $value) {
echo "$key $value";
}*/
}
?>
The last part about the attributes is not working can someone assist me and tell me how to access the attributes of each product in the cart and display them underneath?
/*attributes*/ $available_variations = $_product->get_attribute('pa_groese'); echo "$available_variations";