Get product price in a different currency using WooCommerce Currency Switcher

I am working on some costume products pages in wordpress and I am having kinda of an issue when outputting the product price, the deal is that I am using a plugin to switch the currency and because I have made a lot template changes I had to go with the normal loop way to output products:

foreach($items as $item = $values) { 
        $_product =  wc_get_product( $values['data']-get_id() );
        //product image
        $getProductDetail = wc_get_product( $values['product_id'] );
        //echo "b".$_product-get_title() .'/b  br Quantity: '.$values['quantity'].'br'; 
        //$price = get_post_meta($values['product_id'] , '_price', true);
        $price = $_product-get_price();}

The thing is that I can't change the product's price from the default to price to the currency I chosen. In other hand if I use

$woocommerce-cart-get_cart_total();

it shows me the total in the cart with the currency I picked. Is there anything similar to this for a single product? or a list of products.

Topic woocommerce-offtopic php Wordpress

Category Web


I had the same problem but i solved it using $product->get_price_html() instead of $product->get_price(). That said, keep in mind im using WooCommerce's Multi-Currency for WooCommerce

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.