Skip to content
This repository was archived by the owner on Oct 27, 2022. It is now read-only.

Commit 80cea84

Browse files
authored
Merge pull request #26 from grayloon/sale-price-fix
Allow Special Sale Price to run through current date
2 parents 11765a5 + f68dc59 commit 80cea84

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/Models/MagentoProduct.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ public function salePrice()
161161
}
162162
if ($saleEnd) {
163163
$saleEnd = new Carbon($saleEnd->value);
164+
$saleEnd = $saleEnd->endOfDay();
164165
}
165166

166167
if ($saleStart) {

tests/Models/MagentoProductModelTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,24 @@ public function test_sale_price_with_missing_start_date_before_but_end_date_is_a
343343
$this->assertEquals('9.99', $product->load('customAttributes')->salePrice());
344344
}
345345

346+
public function test_sale_price_runs_through_current_date_on_special_to_date()
347+
{
348+
$product = MagentoProductFactory::new()->create();
349+
350+
$product->customAttributes()->create([
351+
'attribute_type' => 'special_price',
352+
'attribute_type_id' => MagentoCustomAttributeTypeFactory::new()->create(),
353+
'value' => '9.99',
354+
]);
355+
$product->customAttributes()->create([
356+
'attribute_type' => 'special_to_date',
357+
'attribute_type_id' => MagentoCustomAttributeTypeFactory::new()->create(),
358+
'value' => today()->format('Y-m-d H:i:s'),
359+
]);
360+
361+
$this->assertEquals('9.99', $product->load('customAttributes')->salePrice());
362+
}
363+
346364
public function test_configurable_links_has_many_products_through()
347365
{
348366
$configurableProduct = MagentoProductFactory::new()->create();

0 commit comments

Comments
 (0)