-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[project-base] repeat order improvements (#2876)
- Loading branch information
Showing
93 changed files
with
1,662 additions
and
644 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
packages/framework/src/Migrations/Version20231101182132.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrameworkBundle\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Shopsys\FrameworkBundle\Component\Translation\Translator; | ||
use Shopsys\MigrationBundle\Component\Doctrine\Migrations\AbstractMigration; | ||
use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
|
||
class Version20231101182132 extends AbstractMigration implements ContainerAwareInterface | ||
{ | ||
use MultidomainMigrationTrait; | ||
|
||
/** | ||
* @param \Doctrine\DBAL\Schema\Schema $schema | ||
*/ | ||
public function up(Schema $schema): void | ||
{ | ||
foreach ($this->getAllDomainIds() as $domainId) { | ||
$this->setPageContent( | ||
'paymentSuccessfulText', | ||
t(' | ||
<p> | ||
Payment for order number {number} has been successful. <br /><br /> | ||
<a href="{order_detail_url}">Track</a> the status of your order. <br /> | ||
{transport_instructions} | ||
</p>', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $this->getDomainLocale($domainId)), | ||
$domainId, | ||
); | ||
|
||
$this->setPageContent( | ||
'paymentFailedText', | ||
t(' | ||
<p> | ||
Payment for order number {number} has failed. <br /><br /> | ||
Please contact us to resolve the issue. | ||
</p>', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $this->getDomainLocale($domainId)), | ||
$domainId, | ||
); | ||
} | ||
} | ||
|
||
/** | ||
* @param string $settingName | ||
* @param string $pageContent | ||
* @param int $domainId | ||
*/ | ||
private function setPageContent(string $settingName, string $pageContent, int $domainId): void | ||
{ | ||
$paymentSuccessfulPageContent = $this->sql( | ||
'SELECT COUNT(*) FROM setting_values WHERE name = :settingName AND domain_id = :domainId;', | ||
[ | ||
'settingName' => $settingName, | ||
'domainId' => $domainId, | ||
], | ||
)->fetchOne(); | ||
|
||
if ($paymentSuccessfulPageContent > 0) { | ||
return; | ||
} | ||
|
||
$this->sql( | ||
'INSERT INTO setting_values (name, domain_id, value, type) VALUES (:settingName, :domainId, :settingValue, \'string\')', | ||
[ | ||
'settingName' => $settingName, | ||
'settingValue' => $pageContent, | ||
'domainId' => $domainId, | ||
], | ||
); | ||
} | ||
|
||
/** | ||
* @param \Doctrine\DBAL\Schema\Schema $schema | ||
*/ | ||
public function down(Schema $schema): void | ||
{ | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
packages/framework/src/Migrations/Version20231102205308.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrameworkBundle\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Shopsys\MigrationBundle\Component\Doctrine\Migrations\AbstractMigration; | ||
|
||
class Version20231102205308 extends AbstractMigration | ||
{ | ||
/** | ||
* @param \Doctrine\DBAL\Schema\Schema $schema | ||
*/ | ||
public function up(Schema $schema): void | ||
{ | ||
$this->sql(' | ||
ALTER TABLE | ||
orders | ||
ADD | ||
order_payment_status_page_valid_from TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); | ||
$this->sql('ALTER TABLE orders ADD order_payment_status_page_validity_hash UUID DEFAULT NULL'); | ||
$this->sql('ALTER TABLE orders ALTER order_payment_status_page_validity_hash DROP DEFAULT'); | ||
} | ||
|
||
/** | ||
* @param \Doctrine\DBAL\Schema\Schema $schema | ||
*/ | ||
public function down(Schema $schema): void | ||
{ | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
packages/framework/src/Model/Order/ContentPage/OrderContentPageFacade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrameworkBundle\Model\Order\ContentPage; | ||
|
||
use Shopsys\FrameworkBundle\Model\Order\Order; | ||
use Shopsys\FrameworkBundle\Model\Order\OrderFacade; | ||
use Shopsys\FrameworkBundle\Model\Order\OrderUrlGenerator; | ||
|
||
class OrderContentPageFacade | ||
{ | ||
public const VARIABLE_PAYMENT_INSTRUCTIONS = '{payment_instructions}'; | ||
public const VARIABLE_TRANSPORT_INSTRUCTIONS = '{transport_instructions}'; | ||
public const VARIABLE_ORDER_DETAIL_URL = '{order_detail_url}'; | ||
public const VARIABLE_NUMBER = '{number}'; | ||
|
||
/** | ||
* @param \Shopsys\FrameworkBundle\Model\Order\OrderFacade $orderFacade | ||
* @param \Shopsys\FrameworkBundle\Model\Order\OrderUrlGenerator $orderUrlGenerator | ||
* @param \Shopsys\FrameworkBundle\Model\Order\ContentPage\OrderContentPageSettingFacade $orderContentPageSettingFacade | ||
*/ | ||
public function __construct( | ||
protected readonly OrderFacade $orderFacade, | ||
protected readonly OrderUrlGenerator $orderUrlGenerator, | ||
protected readonly OrderContentPageSettingFacade $orderContentPageSettingFacade, | ||
) { | ||
} | ||
|
||
/** | ||
* @param \Shopsys\FrameworkBundle\Model\Order\Order $order | ||
* @return string | ||
*/ | ||
public function getOrderSentPageContent(Order $order): string | ||
{ | ||
$orderSentPageContent = $this->orderContentPageSettingFacade->getOrderSentPageContent($order->getDomainId()); | ||
|
||
return $this->replaceVariables($order, $orderSentPageContent); | ||
} | ||
|
||
/** | ||
* @param \Shopsys\FrameworkBundle\Model\Order\Order $order | ||
* @return string | ||
*/ | ||
public function getPaymentSuccessfulPageContent(Order $order): string | ||
{ | ||
$orderSentPageContent = $this->orderContentPageSettingFacade->getPaymentSuccessfulPageContent($order->getDomainId()); | ||
|
||
return $this->replaceVariables($order, $orderSentPageContent); | ||
} | ||
|
||
/** | ||
* @param \Shopsys\FrameworkBundle\Model\Order\Order $order | ||
* @return string | ||
*/ | ||
public function getPaymentFailedPageContent(Order $order): string | ||
{ | ||
$orderSentPageContent = $this->orderContentPageSettingFacade->getPaymentFailedPageContent($order->getDomainId()); | ||
|
||
return $this->replaceVariables($order, $orderSentPageContent); | ||
} | ||
|
||
/** | ||
* @param \Shopsys\FrameworkBundle\Model\Order\Order $order | ||
* @param string $orderSentPageContent | ||
* @return string | ||
*/ | ||
protected function replaceVariables(Order $order, string $orderSentPageContent): string | ||
{ | ||
$orderDetailUrl = $this->orderUrlGenerator->getOrderDetailUrl($order); | ||
|
||
$variables = [ | ||
self::VARIABLE_TRANSPORT_INSTRUCTIONS => $order->getTransport()->getInstructions(), | ||
self::VARIABLE_PAYMENT_INSTRUCTIONS => $order->getPayment()->getInstructions(), | ||
self::VARIABLE_ORDER_DETAIL_URL => $orderDetailUrl, | ||
self::VARIABLE_NUMBER => $order->getNumber(), | ||
]; | ||
|
||
return strtr($orderSentPageContent, $variables); | ||
} | ||
} |
Oops, something went wrong.