admin管理员组文章数量:1122832
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.
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.
Share Improve this question asked Jan 8, 2020 at 15:38 Mimo_dzMimo_dz 11 bronze badge 1- Which plugin are you using for currency switching? – Andy Mardell Commented Jan 9, 2020 at 16:25
1 Answer
Reset to default 0I 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
本文标签: phpGet product price in a different currency using WooCommerce Currency Switcher
版权声明:本文标题:php - Get product price in a different currency using WooCommerce Currency Switcher 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736289700a1928361.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论