Skip to content

Commit

Permalink
Mage_Shipping - DOC block update (#748)
Browse files Browse the repository at this point in the history
* Mage_Shipping - DOC block update

- doc blocks added/fixed
- PSR2 fixes (whitespaces, linebreaks, ...)

* Fixed mixed return type
  • Loading branch information
sreichel authored Jul 6, 2020
1 parent a5844bf commit 5128e7f
Show file tree
Hide file tree
Showing 30 changed files with 319 additions and 210 deletions.
38 changes: 27 additions & 11 deletions app/code/core/Mage/Shipping/Block/Tracking/Popup.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/**
* Class Mage_Shipping_Block_Tracking_Popup
*
* @method string getProtectCode()
*/
class Mage_Shipping_Block_Tracking_Popup extends Mage_Core_Block_Template
{
/**
Expand All @@ -40,6 +45,8 @@ class Mage_Shipping_Block_Tracking_Popup extends Mage_Core_Block_Template
protected $_ship_id;

/**
* @param int $oid
* @return Mage_Shipping_Block_Tracking_Popup
* @deprecated after 1.3.2.3
*/
public function setOrderId($oid)
Expand All @@ -56,6 +63,8 @@ public function getOrderId()
}

/**
* @param int $oid
* @return Mage_Shipping_Block_Tracking_Popup
* @deprecated after 1.3.2.3
*/
public function setShipId($oid)
Expand All @@ -72,9 +81,11 @@ public function getShipId()
}

/**
* @param string $tid
* @return Mage_Shipping_Block_Tracking_Popup
* @deprecated after 1.3.2.3
*/
public function setTrackId($tid='')
public function setTrackId($tid = '')
{
return $this->setData('track_id', $tid);
}
Expand All @@ -91,7 +102,7 @@ public function getTrackId()
* @deprecated after 1.4.0.0-alpha3
* Initialize order model instance
*
* @return Mage_Sales_Model_Order || false
* @return Mage_Sales_Model_Order|false
*/
protected function _initOrder()
{
Expand All @@ -108,7 +119,7 @@ protected function _initOrder()
* @deprecated after 1.4.0.0-alpha3
* Initialize ship model instance
*
* @return Mage_Sales_Model_Order_Shipment || false
* @return Mage_Sales_Model_Order_Shipment|false
*/
protected function _initShipment()
{
Expand All @@ -129,7 +140,7 @@ protected function _initShipment()
*/
public function getTrackingInfo()
{
/* @var $info Mage_Shipping_Model_Info */
/* @var Mage_Shipping_Model_Info $info */
$info = Mage::registry('current_shipping_info');

return $info->getTrackingInfo();
Expand All @@ -146,12 +157,13 @@ public function getTrackingInfoByOrder()
$shipTrack = array();
if ($order = $this->_initOrder()) {
$shipments = $order->getShipmentsCollection();
foreach ($shipments as $shipment){
/** @var Mage_Sales_Model_Order_Shipment $shipment */
foreach ($shipments as $shipment) {
$increment_id = $shipment->getIncrementId();
$tracks = $shipment->getTracksCollection();

$trackingInfos=array();
foreach ($tracks as $track){
foreach ($tracks as $track) {
$trackingInfos[] = $track->getNumberDetail();
}
$shipTrack[$increment_id] = $trackingInfos;
Expand All @@ -174,11 +186,10 @@ public function getTrackingInfoByShip()
$tracks = $shipment->getTracksCollection();

$trackingInfos=array();
foreach ($tracks as $track){
foreach ($tracks as $track) {
$trackingInfos[] = $track->getNumberDetail();
}
$shipTrack[$increment_id] = $trackingInfos;

}
return $shipTrack;
}
Expand Down Expand Up @@ -218,7 +229,7 @@ public function formatDeliveryDateTime($date, $time)
*/
public function formatDeliveryDate($date)
{
/* @var $locale Mage_Core_Model_Locale */
/* @var Mage_Core_Model_Locale $locale */
$locale = Mage::app()->getLocale();
$format = $locale->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
return $locale->date(strtotime($date), Zend_Date::TIMESTAMP, null, false)
Expand All @@ -238,7 +249,7 @@ public function formatDeliveryTime($time, $date = null)
$time = $date . ' ' . $time;
}

/* @var $locale Mage_Core_Model_Locale */
/* @var Mage_Core_Model_Locale $locale */
$locale = Mage::app()->getLocale();

$format = $locale->getTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
Expand All @@ -256,14 +267,19 @@ public function getContactUsEnabled()
return (bool) Mage::getStoreConfig('contacts/contacts/enabled');
}

/**
* @return string
*/
public function getStoreSupportEmail()
{
return Mage::getStoreConfig('trans_email/ident_support/email');
}

/**
* @return string
*/
public function getContactUs()
{
return $this->getUrl('contacts');
}

}
2 changes: 1 addition & 1 deletion app/code/core/Mage/Shipping/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/


class Mage_Shipping_Exception extends Zend_Exception
class Mage_Shipping_Exception extends Zend_Exception
{

}
35 changes: 20 additions & 15 deletions app/code/core/Mage/Shipping/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,26 @@ public function decodeTrackingHash($hash)
*/
protected function _getTrackingUrl($key, $model, $method = 'getId')
{
if (empty($model)) {
$param = array($key => ''); // @deprecated after 1.4.0.0-alpha3
} else if (!is_object($model)) {
$param = array($key => $model); // @deprecated after 1.4.0.0-alpha3
} else {
$param = array(
'hash' => Mage::helper('core')->urlEncode("{$key}:{$model->$method()}:{$model->getProtectCode()}")
);
}
if (empty($model)) {
$param = array($key => ''); // @deprecated after 1.4.0.0-alpha3
} elseif (!is_object($model)) {
$param = array($key => $model); // @deprecated after 1.4.0.0-alpha3
} else {
$param = array(
'hash' => Mage::helper('core')->urlEncode("{$key}:{$model->$method()}:{$model->getProtectCode()}")
);
}
$storeId = is_object($model) ? $model->getStoreId() : null;
$storeModel = Mage::app()->getStore($storeId);
return $storeModel->getUrl('shipping/tracking/popup', $param);
}

/**
* @param string $order
* @return string
* @deprecated after 1.4.0.0-alpha3
* Retrieve tracking pop up url by order id or object
*
* @param int|Mage_Sales_Model_Order $order
* @return string
*/
public function getTrackingPopUpUrlByOrderId($order = '')
{
Expand All @@ -93,11 +93,11 @@ public function getTrackingPopUpUrlByOrderId($order = '')
}

/**
* @param string $track
* @return string
* @deprecated after 1.4.0.0-alpha3
* Retrieve tracking pop up url by track id or object
*
* @param int|Mage_Sales_Model_Order_Shipment_Track $track
* @return string
*/
public function getTrackingPopUpUrlByTrackId($track = '')
{
Expand All @@ -108,11 +108,11 @@ public function getTrackingPopUpUrlByTrackId($track = '')
}

/**
* @param string $ship
* @return string
* @deprecated after 1.4.0.0-alpha3
* Retrieve tracking pop up url by ship id or object
*
* @param int|Mage_Sales_Model_Order_Shipment $track
* @return string
*/
public function getTrackingPopUpUrlByShipId($ship = '')
{
Expand Down Expand Up @@ -150,6 +150,11 @@ public function getTrackingAjaxUrl()
return $this->_getUrl('shipping/tracking/ajax');
}

/**
* @param string $method
* @param int $storeId
* @return bool
*/
public function isFreeMethod($method, $storeId = null)
{
$arr = explode('_', $method, 2);
Expand Down
58 changes: 36 additions & 22 deletions app/code/core/Mage/Shipping/Model/Carrier/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/


/**
* Class Mage_Shipping_Model_Carrier_Abstract
*
* @method $this setActiveFlag(bool $value)
* @method array getAllowedMethods()
* @method array getContainerTypesAll()
* @method array getContainerTypesFilter()
* @method Mage_Core_Model_Store getStore()
* @method $this setStore(Mage_Core_Model_Store $value)
*/
abstract class Mage_Shipping_Model_Carrier_Abstract extends Varien_Object
{
/**
Expand Down Expand Up @@ -141,7 +150,7 @@ public function requestToShipment(Mage_Shipping_Model_Shipment_Request $request)
* Do return of shipment
* Implementation must be in overridden method
*
* @param $request
* @param mixed $request
* @return Varien_Object
*/
public function returnOfShipment($request)
Expand Down Expand Up @@ -190,7 +199,7 @@ protected function _getAllowedContainers(Varien_Object $params = null)

if ($countryShipper == self::USA_COUNTRY_ID && $countryRecipient == self::USA_COUNTRY_ID) {
$direction = 'within_us';
} else if ($countryShipper == self::USA_COUNTRY_ID && $countryRecipient != self::USA_COUNTRY_ID) {
} elseif ($countryShipper == self::USA_COUNTRY_ID && $countryRecipient != self::USA_COUNTRY_ID) {
$direction = 'from_us';
} else {
return $containersAll;
Expand Down Expand Up @@ -234,35 +243,39 @@ public function getDeliveryConfirmationTypes(Varien_Object $params = null)
return array();
}

/**
* @param Mage_Shipping_Model_Rate_Request $request
* @return $this|bool|false|Mage_Core_Model_Abstract
*/
public function checkAvailableShipCountries(Mage_Shipping_Model_Rate_Request $request)
{
$speCountriesAllow = $this->getConfigData('sallowspecific');
/*
* for specific countries, the flag will be 1
*/
if ($speCountriesAllow && $speCountriesAllow == 1){
if ($speCountriesAllow && $speCountriesAllow == 1) {
$showMethod = $this->getConfigData('showmethod');
$availableCountries = array();
if($this->getConfigData('specificcountry')) {
$availableCountries = explode(',',$this->getConfigData('specificcountry'));
}
if ($availableCountries && in_array($request->getDestCountryId(), $availableCountries)) {
return $this;
} elseif ($showMethod && (!$availableCountries || ($availableCountries
if ($this->getConfigData('specificcountry')) {
$availableCountries = explode(',', $this->getConfigData('specificcountry'));
}
if ($availableCountries && in_array($request->getDestCountryId(), $availableCountries)) {
return $this;
} elseif ($showMethod && (!$availableCountries || ($availableCountries
&& !in_array($request->getDestCountryId(), $availableCountries)))
){
$error = Mage::getModel('shipping/rate_result_error');
$error->setCarrier($this->_code);
$error->setCarrierTitle($this->getConfigData('title'));
$errorMsg = $this->getConfigData('specificerrmsg');
$error->setErrorMessage($errorMsg ? $errorMsg : Mage::helper('shipping')->__('The shipping module is not available for selected delivery country.'));
return $error;
} else {
/*
) {
$error = Mage::getModel('shipping/rate_result_error');
$error->setCarrier($this->_code);
$error->setCarrierTitle($this->getConfigData('title'));
$errorMsg = $this->getConfigData('specificerrmsg');
$error->setErrorMessage($errorMsg ? $errorMsg : Mage::helper('shipping')->__('The shipping module is not available for selected delivery country.'));
return $error;
} else {
/*
* The admin set not to show the shipping module if the devliery country is not within specific countries
*/
return false;
}
}
}
return $this;
}
Expand Down Expand Up @@ -347,7 +360,7 @@ protected function _updateFreeMethodQuote($request)
$freeRateId = false;

if (is_object($this->_result)) {
foreach ($this->_result->getAllRates() as $i=>$item) {
foreach ($this->_result->getAllRates() as $i => $item) {
if ($item->getMethod() == $freeMethod) {
$freeRateId = $i;
break;
Expand Down Expand Up @@ -469,7 +482,7 @@ protected function _getPerorderPrice($cost, $handlingType, $handlingFee)
/**
* Return weight in pounds
*
* @param integer Weight in someone measure
* @param integer $weight Weight in someone measure
* @return float Weight in pounds
*/
public function convertWeightToLbs($weight)
Expand All @@ -480,6 +493,7 @@ public function convertWeightToLbs($weight)
/**
* set the number of boxes for shipping
*
* @param int $weight
* @return float
*/
public function getTotalNumOfBoxes($weight)
Expand Down
16 changes: 9 additions & 7 deletions app/code/core/Mage/Shipping/Model/Carrier/Flatrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
* @category Mage
* @package Mage_Shipping
* @author Magento Core Team <core@magentocommerce.com>
*
* @method int getFreeBoxes()
* @method $this setFreeBoxes(int $value)
*/
class Mage_Shipping_Model_Carrier_Flatrate
extends Mage_Shipping_Model_Carrier_Abstract
implements Mage_Shipping_Model_Carrier_Interface
class Mage_Shipping_Model_Carrier_Flatrate extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface
{

protected $_code = 'flatrate';
Expand All @@ -43,8 +44,8 @@ class Mage_Shipping_Model_Carrier_Flatrate
/**
* Enter description here...
*
* @param Mage_Shipping_Model_Rate_Request $data
* @return Mage_Shipping_Model_Rate_Result
* @param Mage_Shipping_Model_Rate_Request $request
* @return Mage_Shipping_Model_Rate_Result|false
*/
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
Expand All @@ -55,7 +56,6 @@ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
$freeBoxes = 0;
if ($request->getAllItems()) {
foreach ($request->getAllItems() as $item) {

if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
continue;
}
Expand Down Expand Up @@ -108,9 +108,11 @@ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
return $result;
}

/**
* @return array
*/
public function getAllowedMethods()
{
return array('flatrate'=>$this->getConfigData('name'));
}

}
Loading

0 comments on commit 5128e7f

Please sign in to comment.