Dark

Light

Dark

Light

Get cart item name, quantity all details woocommerce

<?php 
global $woocommerce;
$items = $woocommerce->cart->get_cart();
foreach($items as $item => $values) { 
            $_product =  wc_get_product( $values['data']->get_id()); 
echo "<b>".$_product->get_title().'</b>  <br> Quantity: '.$values['quantity'].'<br>'; 
$price = get_post_meta($values['product_id'] , '_price', true);
echo "  Price: ".$price."<br>";
} 
?>

To get Product Image and Regular & Sale Price:

<?php
    global $woocommerce;
    $items = $woocommerce->cart->get_cart();

        foreach($items as $item => $values) { 
            $_product =  wc_get_product( $values['data']->get_id() );
            //product image
            $getProductDetail = wc_get_product( $values['product_id'] );
            echo $getProductDetail->get_image(); // accepts 2 arguments ( size, attr )

            echo "<b>".$_product->get_title() .'</b>  <br> Quantity: '.$values['quantity'].'<br>'; 
            $price = get_post_meta($values['product_id'] , '_price', true);
            echo "  Price: ".$price."<br>";
            /*Regular Price and Sale Price*/
            echo "Regular Price: ".get_post_meta($values['product_id'] , '_regular_price', true)."<br>";
            echo "Sale Price: ".get_post_meta($values['product_id'] , '_sale_price', true)."<br>";
        }
?>

Post a comment

Your email address will not be published.

11 comments

  1. Santossep

    https://zithromaxproff.com/# buy azithromycin zithromax
    can you buy zithromax over the counter in australia

  2. BillyBom

    biaxin for sale: buy stromectol online
    omnicef price

  3. MichaelDiund

    overseas pharmacies shipping to usa: reputable online pharmacies in india ordering medicine from india

  4. MichaelDiund

    meds from india: generic pills india generic pills india

  5. Michaelgox

    viagra cost: no prescription viagra viagra without prescription

  6. Michaelgox

    viagra from india: viagra without a doctor prescription usa viagra online without prescription

  7. Claudaluck

    amoxicillin 500mg over the counter: generic amoxil – amoxicillin without a prescription

  8. Claudaluck

    clomid capsules 50mg: clomid for sale – clomid 50 mg

  9. Claudaluck

    doxylin: doxycycline – buy doxycycline 100mg

  10. Claudaluck

    where to buy amoxicillin 500mg: amoxicillin without a doctors prescription – cost of amoxicillin 30 capsules

test