To load commerce currency and symbol,
Load the commerce product using the product variation id,
$product = ProductVariation::load($id);
if (!is_object($product)) {
return;
}
// Extract the price.
$price_data = $product->getPrice();
$currency_code = $price_data->getCurrencyCode();
// Get currency symbol using the loaded currency code.
$symbol = \Drupal::entityTypeManager()->getStorage('commerce_currency')->load($currency_code)->getSymbol();
- Log in to post comments
Category