Skip to content
This repository has been archived by the owner on Aug 1, 2018. It is now read-only.

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenix128 committed Sep 12, 2017
1 parent e069cba commit c84be51
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
24 changes: 8 additions & 16 deletions Block/Sales/Cashondelivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@

class Cashondelivery extends Template
{
protected $_source;
protected $_order;

public function getSource()
{
return $this->_source;
}

public function displayFullSummary()
{
return true;
Expand All @@ -45,12 +37,10 @@ public function displayFullSummary()
public function initTotals()
{
$parent = $this->getParentBlock();
$source = $parent->getSource();

$this->_source = $parent->getSource();
$source = $this->getSource();


if ($this->getPayment($source)->getMethod() == Payment::CODE) {
$payment = $this->getPayment($source);
if ($payment && ($payment->getMethod() == Payment::CODE)) {
$fee = new DataObject(
[
'code' => 'msp_cashondelivery',
Expand All @@ -68,16 +58,18 @@ public function initTotals()

protected function getPayment($source)
{
if($source instanceof InvoiceInterface) {
if ($source instanceof InvoiceInterface) {
return $source->getOrder()->getPayment();
}

if($source instanceof OrderInterface) {
if ($source instanceof OrderInterface) {
return $source->getPayment();
}

if($source instanceof CreditMemoInterface) {
if ($source instanceof CreditMemoInterface) {
return $source->getOrder()->getPayment();
}

return null;
}
}
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="MSP_CashOnDelivery" setup_version="1.2.2">
<module name="MSP_CashOnDelivery" setup_version="1.2.3">
<sequence>
<module name="Magento_Sales" />
<module name="Magento_Payment" />
Expand Down

0 comments on commit c84be51

Please sign in to comment.