Skip to content

Commit

Permalink
Merge pull request #64 from frankmullenger/price-class-override
Browse files Browse the repository at this point in the history
MINOR replace new Price() with Price::create() to allow it to be overrid...
  • Loading branch information
stevie-mayhew committed Jul 4, 2014
2 parents 61e364e + 03d3a86 commit 762a79b
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion code/form/ProductForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct($controller, $name, $quantity = null, $redirectURL =
if ($variation->isEnabled()) {
$variationPrice = $variation->Price();

$amount = new Price();
$amount = Price::create();
$amount->setAmount($productPrice->getAmount() + $variationPrice->getAmount());
$amount->setCurrency($productPrice->getCurrency());
$amount->setSymbol($productPrice->getSymbol());
Expand Down
2 changes: 1 addition & 1 deletion code/order/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function Amount() {

$order = $this->Order();

$amount = new Price();
$amount = Price::create();
$amount->setAmount($this->Price);
$amount->setCurrency($order->BaseCurrency);
$amount->setSymbol($order->BaseCurrencySymbol);
Expand Down
2 changes: 1 addition & 1 deletion code/order/ItemOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function Amount() {

$order = $this->Order();

$amount = new Price();
$amount = Price::create();
$amount->setAmount($this->Price);
$amount->setCurrency($order->BaseCurrency);
$amount->setSymbol($order->BaseCurrencySymbol);
Expand Down
2 changes: 1 addition & 1 deletion code/order/Modification.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function Amount() {
// TODO: Multi currency
$order = $this->Order();

$amount = new Price();
$amount = Price::create();
$amount->setAmount($this->Price);
$amount->setCurrency($order->BaseCurrency);
$amount->setSymbol($order->BaseCurrencySymbol);
Expand Down
8 changes: 4 additions & 4 deletions code/order/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function Total() {

// TODO: Multi currency

$amount = new Price();
$amount = Price::create();
$amount->setAmount($this->TotalPrice);
$amount->setCurrency($this->BaseCurrency);
$amount->setSymbol($this->BaseCurrencySymbol);
Expand All @@ -74,7 +74,7 @@ public function SubTotal() {

// TODO: Multi currency

$amount = new Price();
$amount = Price::create();
$amount->setAmount($this->SubTotalPrice);
$amount->setCurrency($this->BaseCurrency);
$amount->setSymbol($this->BaseCurrencySymbol);
Expand Down Expand Up @@ -475,7 +475,7 @@ public function TotalOutstanding() {

// TODO: Multi currency

$outstanding = new Price();
$outstanding = Price::create();
$outstanding->setAmount($total);
$outstanding->setCurrency($this->BaseCurrency);
$outstanding->setSymbol($this->BaseCurrencySymbol);
Expand All @@ -498,7 +498,7 @@ public function TotalPaid() {
}
}

$totalPaid = new Price();
$totalPaid = Price::create();
$totalPaid->setAmount($paid);
$totalPaid->setCurrency($this->BaseCurrency);
$totalPaid->setSymbol($this->BaseCurrencySymbol);
Expand Down
2 changes: 1 addition & 1 deletion code/product/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function Amount() {
// TODO: Multi currency
$shopConfig = ShopConfig::current_shop_config();

$amount = new Price();
$amount = Price::create();
$amount->setAmount($this->Price);
$amount->setCurrency($shopConfig->BaseCurrency);
$amount->setSymbol($shopConfig->BaseCurrencySymbol);
Expand Down
2 changes: 1 addition & 1 deletion code/product/Variation.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Variation extends DataObject implements PermissionProvider {

public function Amount() {

$amount = new Price();
$amount = Price::create();
$amount->setCurrency($this->Currency);
$amount->setAmount($this->Price);
$amount->setSymbol(ShopConfig::current_shop_config()->BaseCurrencySymbol);
Expand Down
2 changes: 1 addition & 1 deletion tests/CartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public function testAddProductToCartChangePrice() {
$this->assertEquals(1, $order->Items()->Count());
$this->assertEquals($productA->Price, $firstItem->Price);

$newAmount = new Price();
$newAmount = Price::create();
$newAmount->setAmount(72.34);
$newAmount->setCurrency('NZD');

Expand Down

0 comments on commit 762a79b

Please sign in to comment.