Skip to content

Commit ca46f18

Browse files
committed
hide flat rate shipping for non recurring orders
1 parent a0b74f3 commit ca46f18

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Ordergroove\Subscription\Model\Carrier;
4+
5+
class Flatrate{
6+
7+
protected $_checkoutSession;
8+
protected $_scopeConfig;
9+
protected $_customerSession;
10+
11+
public function __construct(
12+
\Magento\Checkout\Model\Session $checkoutSession,
13+
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
14+
\Magento\Store\Model\StoreManagerInterface $storeManager,
15+
\Magento\Customer\Model\Session $customerSession
16+
) {
17+
$this->_storeManager = $storeManager;
18+
$this->_checkoutSession = $checkoutSession;
19+
$this->_scopeConfig = $scopeConfig;
20+
$this->_customerSession = $customerSession;
21+
}
22+
23+
public function afterCollectRates(\Magento\OfflineShipping\Model\Carrier\Flatrate $Flatrate, $result)
24+
{
25+
$url = $this->_storeManager->getStore()->getCurrentUrl(false);
26+
$path = parse_url($url)['path'];
27+
if ($path == '/ordergroove/subscription/placeorder') {
28+
return $result;
29+
}
30+
return false;
31+
}
32+
33+
}

etc/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
4+
<type name="Magento\OfflineShipping\Model\Carrier\Flatrate">
5+
<plugin name="ordergroove_disable_flatrate_on_checkout" type="Ordergroove\Subscription\Model\Carrier\DisableFlatratePlugin" sortOrder="1" />
6+
</type>
47
<type name="Magento\Config\Model\Config\TypePool">
58
<arguments>
69
<argument name="sensitive" xsi:type="array">

0 commit comments

Comments
 (0)