Skip to content

Commit

Permalink
Merge pull request #172 from bold-commerce/Q1-615
Browse files Browse the repository at this point in the history
Q1-615: Fix module compatibility.
  • Loading branch information
nmalevanec authored Nov 6, 2023
2 parents ae81120 + af74d2f commit 75f7930
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
22 changes: 22 additions & 0 deletions Model/GetParallelCheckoutTemplate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace Bold\Checkout\Model;

/**
* Get template for the parallel checkout button.
*/
class GetParallelCheckoutTemplate
{
private const PARALLEL_CHECKOUT_TEMPLATE = 'Bold_Checkout::cart/checkout_button.phtml';

/**
* Get template for the parallel checkout button.
*
* @return string
*/
public function getTemplate(): string {
return self::PARALLEL_CHECKOUT_TEMPLATE;
}
}
16 changes: 14 additions & 2 deletions Observer/Checkout/AddParallelCheckoutButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Bold\Checkout\Observer\Checkout;

use Bold\Checkout\Block\Onepage\Button;
use Bold\Checkout\Model\GetParallelCheckoutTemplate;
use Magento\Catalog\Block\ShortcutButtons;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
Expand All @@ -15,7 +16,18 @@
*/
class AddParallelCheckoutButton implements ObserverInterface
{
private const PARALLEL_CHECKOUT_TEMPLATE = 'Bold_Checkout::cart/checkout_button.phtml';
/**
* @var GetParallelCheckoutTemplate
*/
private $getParallelCheckoutTemplate;

/**
* @param GetParallelCheckoutTemplate $getParallelCheckoutTemplate
*/
public function __construct(GetParallelCheckoutTemplate $getParallelCheckoutTemplate)
{
$this->getParallelCheckoutTemplate = $getParallelCheckoutTemplate;
}

/**
* Add parallel checkout button to shortcut buttons container.
Expand All @@ -32,7 +44,7 @@ public function execute(Observer $observer)
}
$params = [
'data' => [
'template' => self::PARALLEL_CHECKOUT_TEMPLATE,
'template' => $this->getParallelCheckoutTemplate->getTemplate(),
],
];
/** @var ShortcutButtons $shortcutButtons */
Expand Down
3 changes: 0 additions & 3 deletions etc/events.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
<event name="catalog_product_import_bunch_delete_after">
<observer name="bold_checkout_product_import_delete" instance="Bold\Checkout\Observer\Product\Import\ProductImportDelete"/>
</event>
<event name="shortcut_buttons_container">
<observer name="bold_checkout_parallel_checkout_button" instance="Bold\Checkout\Observer\Checkout\AddParallelCheckoutButton"/>
</event>
<event name="add_comments_to_order_save_before">
<observer name="add_order_comment_quote_total_diff_bold_order_total" instance="Bold\Checkout\Observer\Order\AddOrderCommentQuoteTotalDiffBoldOrderTotalObserver"/>
</event>
Expand Down
3 changes: 3 additions & 0 deletions etc/frontend/events.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
<event name="controller_action_predispatch_onestepcheckout_index_index">
<observer name="redirect_to_bold_checkout" instance="Bold\Checkout\Observer\Checkout\RedirectToBoldCheckoutObserver"/>
</event>
<event name="shortcut_buttons_container">
<observer name="bold_checkout_parallel_checkout_button" instance="Bold\Checkout\Observer\Checkout\AddParallelCheckoutButton"/>
</event>
</config>

0 comments on commit 75f7930

Please sign in to comment.