diff --git a/Plugin/Catalog/Helper/Product/Configuration.php b/Plugin/Catalog/Helper/Product/Configuration.php new file mode 100644 index 00000000..d63b6b45 --- /dev/null +++ b/Plugin/Catalog/Helper/Product/Configuration.php @@ -0,0 +1,78 @@ +pagarmeConfig = Magento2CoreSetup::getModuleConfiguration(); + $this->recurrenceService = $recurrenceService; + } + + /** + * @param ConfigurationOriginal $subject + * @param callable $proceed + * @param ItemInterface $item + * @return array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundGetCustomOptions( + ConfigurationOriginal $subject, + callable $proceed, + ItemInterface $item + ) { + $result = $proceed($item); + + $product = $item->getProduct(); + $hasNoRecurrence = !$this->pagarmeConfig->isEnabled() || + !$this->pagarmeConfig->getRecurrenceConfig()->isEnabled() || + empty($this->recurrenceService->getRecurrenceProductByProductId($product->getId())); + if ($hasNoRecurrence) { + return $result; + } + + $updateCycleValueCallback = function ($item) use ($product) { + if (ucfirst(RecurrenceSubscriptionRepetitionsInterface::CYCLES) !== $item['label']) { + return $item; + } + + $item['value'] = ProductHelper::applyDiscount($item['value'], $product); + return $item; + }; + + return array_map($updateCycleValueCallback, $result); + } +} diff --git a/Plugin/Princing/Render/ProductPriceCyclesPlugin.php b/Plugin/Princing/Render/ProductPriceCyclesPlugin.php deleted file mode 100644 index e3ecc232..00000000 --- a/Plugin/Princing/Render/ProductPriceCyclesPlugin.php +++ /dev/null @@ -1,40 +0,0 @@ -productHelper = $productHelper; - } - - public function beforeSetTemplate() - { - return ['Pagarme_Pagarme::product/priceCycles.phtml']; - } - - /** - * @param string $title - * @param Product $product - * @return string - */ - public static function applyDiscount($title, $product) - { - return ProductHelper::applyDiscount($title, $product); - } -} diff --git a/etc/di.xml b/etc/di.xml index c0696c91..6a70e44c 100755 --- a/etc/di.xml +++ b/etc/di.xml @@ -659,10 +659,6 @@ - - - - diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml index eed647e8..21b3a5c5 100755 --- a/etc/frontend/di.xml +++ b/etc/frontend/di.xml @@ -76,4 +76,11 @@ + + + + diff --git a/view/frontend/templates/product/priceCycles.phtml b/view/frontend/templates/product/priceCycles.phtml deleted file mode 100644 index 8d0d122e..00000000 --- a/view/frontend/templates/product/priceCycles.phtml +++ /dev/null @@ -1,135 +0,0 @@ -getItem(); -$product = $_item->getProduct(); -$isVisibleProduct = $product->isVisibleInSiteVisibility(); -/** @var \Magento\Msrp\Helper\Data $helper */ -$helper = $this->helper(Magento\Msrp\Helper\Data::class); -$canApplyMsrp = $helper->isShowBeforeOrderConfirm($product) && $helper->isMinimalPriceLessMsrp($product); -?> - - - - hasProductUrl()) :?> - - - - - getImage($block->getProductForThumbnail(), 'cart_page_product_thumbnail')->toHtml() ?> - hasProductUrl()) :?> - - - - -
- - hasProductUrl()) :?> - escapeHtml($block->getProductName()) ?> - - escapeHtml($block->getProductName()) ?> - - - getOptionList()) :?> -
- - - getFormatedOptionValue($_option) ?> -
escapeHtml($_option['label']) ?>
-
- - escapeHtml($_formatedOptionValue['full_view']) ?> - - escapeHtml($_formatedOptionValue['value'], ['span', 'a']) ?> - -
- -
- - getMessages()) :?> - -
-
escapeHtml($message['text']) ?>
-
- - - getProductAdditionalInformationBlock(); ?> - - setItem($_item)->toHtml() ?> - -
- - - - - - escapeHtml(__('See price before order confirmation.')) ?> - getId(); ?> - - escapeHtml(__("What's this?")) ?> - - - - - - getUnitPriceHtml($_item) ?> - - - -
-
- -
-
- - - - - -- - - getRowTotalHtml($_item) ?> - - - - - -
- getActions($_item) ?> -
- - -