-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MOL-1196: Tracking #607
MOL-1196: Tracking #607
Changes from 4 commits
d548cb8
cfd494e
d5d81db
8f63450
2dbf5af
c947525
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Kiener\MolliePayments\Service; | ||
|
||
use Kiener\MolliePayments\Struct\MollieApi\ShipmentTrackingInfoStruct; | ||
use Shopware\Core\Checkout\Order\Aggregate\OrderDelivery\OrderDeliveryEntity; | ||
|
||
class TrackingInfoStructFactory | ||
boxblinkracer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
public function createFromDelivery(OrderDeliveryEntity $orderDeliveryEntity):?ShipmentTrackingInfoStruct | ||
{ | ||
$trackingCodes = $orderDeliveryEntity->getTrackingCodes(); | ||
$shippingMethod = $orderDeliveryEntity->getShippingMethod(); | ||
if ($shippingMethod === null) { | ||
return null; | ||
} | ||
if (count($trackingCodes) !== 1) { | ||
return null; | ||
boxblinkracer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
return $this->create((string)$shippingMethod->getName(), $trackingCodes[0], (string)$shippingMethod->getTrackingUrl()); | ||
} | ||
|
||
public function create(string $trackingCarrier, string $trackingCode, string $trackingUrl): ?ShipmentTrackingInfoStruct | ||
{ | ||
if (empty($trackingCarrier) && empty($trackingCode)) { | ||
return null; | ||
} | ||
|
||
if (empty($trackingCarrier)) { | ||
throw new \InvalidArgumentException('Missing Argument for Tracking Carrier!'); | ||
} | ||
|
||
if (empty($trackingCode)) { | ||
throw new \InvalidArgumentException('Missing Argument for Tracking Code!'); | ||
} | ||
|
||
$trackingUrl = trim($trackingUrl . $trackingCode); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this does not work, thats just a string concat There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in SW6 there is trackingCode variable just in email, the URL itself does not have a tracking Code https://docs.shopware.com/en/shopware-6-en/tutorials-and-faq/track-and-trace it seems like sw6 expects that the tracking code is at the end of the URL There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope, the info icon says clearly its the placeholder %s |
||
|
||
if (filter_var($trackingUrl, FILTER_VALIDATE_URL) === false) { | ||
$trackingUrl = ''; | ||
} | ||
|
||
/** | ||
* following characters are not allowed in the tracking URL {,},<,>,# | ||
*/ | ||
if (preg_match_all('/[{}<>#]/m', $trackingUrl)) { | ||
$trackingUrl = ''; | ||
} | ||
|
||
return new ShipmentTrackingInfoStruct($trackingCarrier, $trackingCode, $trackingUrl); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really wondering, this PR is about automating tracking in whatever shipping is being done.
so if we extract tracking from delivery in the constructor....then i would assume its used somewhere, but i only see function arguments being used here, and the calling instance doesnt seem to have changed which means its the old logic? so where is the auto-extracted data then used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the shipment facade is too big and too much things, the tests are too complicated, i wanted to extract some private methods into seperate services in order to write smaller tests. the factory is not used anywhere else but it makes the tests easier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesnt really give an answer to the question
i think we should talk about it :)