Source of file ProductExtension.php
Size: 1,203 Bytes - Last Modified: 2021-12-23T10:03:46+00:00
/var/www/docs.ssmods.com/process/src/code/extensions/ProductExtension.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445 | <?php class ProductExtension extends DataExtension { private static $casting = array( "CurrencyPrice" => 'Currency' ); public function getCurrencyPrice() { if($currentCurrency = Session::get('Currency')){ $currencyRate = ExchangeRate::get()->filter(array("Currency" => $currentCurrency))->first(); if($currencyRate && $currencyRate->exists()){ $convertedPrice = $this->owner->getField('BasePrice') * $currencyRate->Rate; return $convertedPrice; } } // no currency other than base return false; } // Disabled for now. // Not ideal as it changes it throughout the whole checkout process meaning the user pays less in some cases. // re-wroking logic // // public function getBasePrice() { // // if($currentCurrency = Session::get('Currency')){ // $currencyRate = ExchangeRate::get()->filter(array("Currency" => $currentCurrency))->first(); // if($currencyRate && $currencyRate->exists()){ // // $convertedPrice = $this->owner->getField('BasePrice') * $currencyRate->Rate; // // return $convertedPrice; // } // } // // return $this->owner->getField('BasePrice'); // } } |