Skip to content

Commit 71e3678

Browse files
committed
OXDEV-8721 Fix duplicate shipping costs calculation
1 parent cf4849b commit 71e3678

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

CHANGELOG-7.3.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
### Fixed
1212
- Shop ID resolution considers SSL language URLs
1313
- Email existence check when changing from user to guest email [#0006860](https://bugs.oxid-esales.com/view.php?id=6860)
14+
- Shipping costs calculation in cart and checkout after login [#0007682](https://bugs.oxid-esales.com/view.php?id=7682)
1415

1516
### Changed
1617
- Raised minimum required version of Symfony components to 6.4

source/Application/Model/Delivery.php

+4
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,10 @@ public function delete($sOxId = null)
329329
*/
330330
public function isForBasket($oBasket)
331331
{
332+
$this->_iItemCnt = 0;
333+
$this->_iProdCnt = 0;
334+
$this->_dPrice = 0;
335+
332336
// amount for conditional check
333337
$blHasArticles = $this->hasArticles();
334338
$blHasCategories = $this->hasCategories();

tests/Integration/Legacy/Price/DeliveryCostTest.php

+26
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,30 @@ public function testGetDeliveryListWithRuleAssignedWillSkipWrongRule($testCase):
117117
$this->assertCount(1, $suitableDeliveries);
118118
$this->assertEquals('ok-rule', reset($suitableDeliveries)->getFieldData('oxtitle'));
119119
}
120+
121+
#[DataProvider('providerDeliveryCostRules')]
122+
public function testDeliveryCostNotDoubledWithSameDeliveryObject(array $testCase): void
123+
{
124+
$basket = (new BasketConstruct())->calculateBasket($testCase);
125+
126+
$user = oxNew(User::class);
127+
$user->load($testCase['user']['oxid']);
128+
$deliveryList = oxNew(DeliveryList::class);
129+
$deliveries = $deliveryList->getDeliveryList(
130+
$basket,
131+
$user,
132+
BasketConstruct::getDefaultCountryId(),
133+
$basket->getShippingId()
134+
);
135+
$delivery = reset($deliveries);
136+
137+
$delivery->isForBasket($basket);
138+
$firstPrice = $delivery->getDeliveryPrice()->getBruttoPrice();
139+
140+
$delivery->setDeliveryPrice(null);
141+
$delivery->isForBasket($basket);
142+
$secondPrice = $delivery->getDeliveryPrice()->getBruttoPrice();
143+
144+
$this->assertEquals($firstPrice, $secondPrice);
145+
}
120146
}

0 commit comments

Comments
 (0)