-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from Paazl/1.1.3
Combined 1.1.3 edits
- Loading branch information
Showing
19 changed files
with
979 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* Copyright © 2019 Paazl. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Paazl\CheckoutWidget\Api\Data\Delivery; | ||
|
||
/** | ||
* Paazl Order Pickup Location Interface | ||
* | ||
* @api | ||
*/ | ||
interface OrderPickupLocationInterface | ||
{ | ||
const PICKUP_CODE = 'pickup_code'; | ||
const NAME = 'name'; | ||
const COUNTRY = 'country'; | ||
const POSTCODE = 'postcode'; | ||
const CITY = 'city'; | ||
const STREET = 'street'; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getPickupCode(); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName(); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCountry(); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getPostcode(); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCity(); | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public function getStreet(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
/** | ||
* Copyright © 2019 Paazl. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Paazl\CheckoutWidget\Model\Delivery; | ||
|
||
use Magento\Framework\Model\AbstractModel; | ||
use Paazl\CheckoutWidget\Api\Data\Delivery\OrderPickupLocationInterface; | ||
|
||
/** | ||
* Paazl Order Pickup Location Entity | ||
*/ | ||
class OrderPickupLocation extends AbstractModel implements OrderPickupLocationInterface | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function getPickupCode() | ||
{ | ||
return $this->getData(OrderPickupLocationInterface::PICKUP_CODE); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->getData(OrderPickupLocationInterface::NAME); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCountry() | ||
{ | ||
return $this->getData(OrderPickupLocationInterface::COUNTRY); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getPostcode() | ||
{ | ||
return $this->getData(OrderPickupLocationInterface::POSTCODE); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCity() | ||
{ | ||
return $this->getData(OrderPickupLocationInterface::CITY); | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public function getStreet() | ||
{ | ||
return $this->getData(OrderPickupLocationInterface::STREET); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* Copyright © 2019 Paazl. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Paazl\CheckoutWidget\Model\Handler; | ||
|
||
use Magento\Framework\Exception\LocalizedException; | ||
use Magento\Framework\Model\AbstractExtensibleModel; | ||
use Magento\Sales\Model\Order\Item as OrderItem; | ||
use Magento\Quote\Model\Quote\Item as QuoteItem; | ||
use Paazl\CheckoutWidget\Helper\General as GeneralHelper; | ||
|
||
/** | ||
* Handler Quote or Order Item | ||
*/ | ||
class Item | ||
{ | ||
/** | ||
* @var GeneralHelper | ||
*/ | ||
private $generalHelper; | ||
|
||
public function __construct(GeneralHelper $generalHelper) | ||
{ | ||
$this->generalHelper = $generalHelper; | ||
} | ||
|
||
/** | ||
* Gets formatted price from quote or order item | ||
* When price value = 0 method will return value equivalent 0.01 | ||
* | ||
* @param $item | ||
* @return string | ||
* @throws LocalizedException | ||
*/ | ||
public function getPriceValue(AbstractExtensibleModel $item) | ||
{ | ||
if (!($item instanceof OrderItem) && !($item instanceof QuoteItem)) { | ||
$exception = new LocalizedException( | ||
__('Cannot get price value from the item. Item must be Item from Quote or Item from Order.') | ||
); | ||
$this->generalHelper->addTolog('exception', $exception->getMessage()); | ||
throw $exception; | ||
} | ||
|
||
if ($item->getParentItemId() > 0) { | ||
$priceValue = $item->getParentItem()->getPriceInclTax(); | ||
} else { | ||
$priceValue = $item->getPriceInclTax(); | ||
} | ||
|
||
return $priceValue <= 0.01 ? 0.01 : $priceValue; | ||
} | ||
} |
Oops, something went wrong.