diff --git a/vendor/magento/module-purchase-order/Block/Checkout/LayoutProcessor.php b/vendor/magento/module-purchase-order/Block/Checkout/LayoutProcessor.php
deleted file mode 100644
index 650db233457..00000000000
--- a/vendor/magento/module-purchase-order/Block/Checkout/LayoutProcessor.php
+++ /dev/null
@@ -1,61 +0,0 @@
-config = $config;
- }
-
- /**
- * @inheritDoc
- */
- public function process($jsLayout)
- {
- $isEnabled = $this->config->isEnabledForCurrentCustomerAndWebsite();
-
- if ($isEnabled) {
- if (isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step'])) {
- $jsLayout
- ['components']
- ['checkout']
- ['children']
- ['steps']
- ['children']
- ['billing-step']
- ['children']
- ['payment']
- ['children']
- ['afterMethods']
- ['children']
- ['discount']
- ['config']
- ['componentDisabled'] = true;
- }
- }
-
- return $jsLayout;
- }
-}
diff --git a/vendor/magento/module-purchase-order/Model/PurchaseOrderManagement.php b/vendor/magento/module-purchase-order/Model/PurchaseOrderManagement.php
index 32ea3797730..876dd7dd14a 100644
--- a/vendor/magento/module-purchase-order/Model/PurchaseOrderManagement.php
+++ b/vendor/magento/module-purchase-order/Model/PurchaseOrderManagement.php
@@ -410,6 +410,7 @@ public function approvePurchaseOrder(PurchaseOrderInterface $purchaseOrder, $act
private function placeOrder(CartInterface $quote)
{
$quote->setIsActive(true);
+ $quote->setTotalsCollectedFlag(true);
$this->quoteRepository->save($quote);
try {
diff --git a/vendor/magento/module-purchase-order/Plugin/Checkout/Controller/Cart/IndexPlugin.php b/vendor/magento/module-purchase-order/Plugin/Checkout/Controller/Cart/IndexPlugin.php
deleted file mode 100644
index 0434ad86af2..00000000000
--- a/vendor/magento/module-purchase-order/Plugin/Checkout/Controller/Cart/IndexPlugin.php
+++ /dev/null
@@ -1,54 +0,0 @@
-config = $config;
- }
-
- /**
- * After CartIndexControllerAction::execute; remove checkout.cart.coupon if Purchase Order is enabled
- *
- * @param CartIndexControllerAction $subject
- * @param Page $result
- * @return Page
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function afterExecute(CartIndexControllerAction $subject, $result)
- {
- if (!$this->config->isEnabledForCurrentCustomerAndWebsite()) {
- return $result;
- }
-
- $block = $result->getLayout()->getBlock('checkout.cart.coupon');
- if ($block) {
- $result->getLayout()->unsetElement('checkout.cart.coupon');
- }
-
- return $result;
- }
-}
diff --git a/vendor/magento/module-purchase-order/Plugin/Quote/Model/QuoteManagementPlugin.php b/vendor/magento/module-purchase-order/Plugin/Quote/Model/QuoteManagementPlugin.php
new file mode 100644
index 00000000000..d1b05ca6fdb
--- /dev/null
+++ b/vendor/magento/module-purchase-order/Plugin/Quote/Model/QuoteManagementPlugin.php
@@ -0,0 +1,72 @@
+purchaseOrderRepository = $purchaseOrderRepository;
+ }
+
+ /**
+ * Restore order applied rules from Purchase Order quote
+ *
+ * @param QuoteManagement $subject
+ * @param \Closure $proceed
+ * @param CartInterface $quote
+ * @param array $orderData
+ * @return OrderInterface
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function aroundSubmit(
+ QuoteManagement $subject,
+ \Closure $proceed,
+ CartInterface $quote,
+ $orderData = []
+ ) {
+ $order = $proceed($quote, $orderData);
+ if ($this->isPurchaseOrderQuote($quote) && $order) {
+ if ($quote->getAppliedRuleIds() === null) {
+ $order->setAppliedRuleIds('');
+ } else {
+ $order->setAppliedRuleIds($quote->getAppliedRuleIds());
+ }
+ }
+ return $order;
+ }
+
+ /**
+ * Check if quote is using for Purchase Order
+ *
+ * @param CartInterface $quote
+ * @return bool
+ */
+ private function isPurchaseOrderQuote(CartInterface $quote)
+ {
+ $purchaseOrder = $this->purchaseOrderRepository->getByQuoteId($quote->getId());
+ return ($purchaseOrder->getEntityId()) ? true : false;
+ }
+}
diff --git a/vendor/magento/module-purchase-order/Plugin/Quote/Model/QuoteRepositoryPlugin.php b/vendor/magento/module-purchase-order/Plugin/Quote/Model/QuoteRepositoryPlugin.php
new file mode 100644
index 00000000000..77c41026c78
--- /dev/null
+++ b/vendor/magento/module-purchase-order/Plugin/Quote/Model/QuoteRepositoryPlugin.php
@@ -0,0 +1,66 @@
+purchaseOrderRepository = $purchaseOrderRepository;
+ }
+
+ /**
+ * Call after get active quote from quote repository
+ *
+ * Set total collected flag to true to prevent collect totals calls if
+ * quote is used for Purchase Order and trigger_recollect is false
+ *
+ * @param CartRepositoryInterface $subject
+ * @param CartInterface $quote
+ * @return CartInterface
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function afterGetActive(
+ CartRepositoryInterface $subject,
+ CartInterface $quote
+ ) {
+ if ($this->isPurchaseOrderQuote($quote) && !$quote->getData('trigger_recollect')) {
+ $quote->setTotalsCollectedFlag(true);
+ }
+ return $quote;
+ }
+
+ /**
+ * Check if quote is using for Purchase Order
+ *
+ * @param CartInterface $quote
+ * @return bool
+ */
+ private function isPurchaseOrderQuote(CartInterface $quote)
+ {
+ $purchaseOrder = $this->purchaseOrderRepository->getByQuoteId($quote->getId());
+ return ($purchaseOrder->getEntityId()) ? true : false;
+ }
+}
diff --git a/vendor/magento/module-purchase-order/etc/di.xml b/vendor/magento/module-purchase-order/etc/di.xml
index c84db4ba8d7..369ae3458e7 100644
--- a/vendor/magento/module-purchase-order/etc/di.xml
+++ b/vendor/magento/module-purchase-order/etc/di.xml
@@ -253,4 +253,13 @@
+
+
+
+
+
+
+
diff --git a/vendor/magento/module-purchase-order/etc/frontend/di.xml b/vendor/magento/module-purchase-order/etc/frontend/di.xml
index 9e013cf8707..a871a869b73 100644
--- a/vendor/magento/module-purchase-order/etc/frontend/di.xml
+++ b/vendor/magento/module-purchase-order/etc/frontend/di.xml
@@ -9,19 +9,8 @@
-
-
- -
- Magento\PurchaseOrder\Block\Checkout\LayoutProcessor
-
-
-
-
-
-