Answers for "woocommerce cart data"

0

get regular price from cartitem 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>";
        } 
?>
Posted by: Guest on June-12-2020
0

woocommerce show data to cart page

add_filter( "woocommerce_get_item_data", "cs_get_item_data", 10,2 );
function cs_get_item_data( $data, $cart_item ){
  if ( isset( $cart_item['singleFood'] ) ) {
    $data[] = array(
        'name'    => 'Choosen Custom Food Items',
        'value'   => sanitize_text_field( $cart_item['singleFood'] ),
      );
  }
  return $data;
}
Posted by: Guest on May-08-2021
0

get regular price from cartitem woocommerce

<?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>";
        }
?>
Posted by: Guest on June-12-2020

Browse Popular Code Answers by Language