Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief EasyPost Shipping Rate
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 19 Jun 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Flat Shipping Rate Node
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 13 Feb 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -234,9 +234,9 @@ class _FlatRate extends \IPS\Node\Model implements \IPS\nexus\Shipping\Rate
|
||||
{
|
||||
$rates = array();
|
||||
/* Populate */
|
||||
foreach ( $values[ "s_rates_{$values['s_type']}" ] as $rate )
|
||||
{
|
||||
if ( $rate["{$values['s_type']}_rate_min"] == '*' )
|
||||
foreach ( $values[ "s_rates_{$values['s_type']}" ] as $k => $rate )
|
||||
{
|
||||
if ( $rate["{$values['s_type']}_rate_min"] === '*' )
|
||||
{
|
||||
$min = '*';
|
||||
}
|
||||
@@ -260,7 +260,7 @@ class _FlatRate extends \IPS\Node\Model implements \IPS\nexus\Shipping\Rate
|
||||
}
|
||||
}
|
||||
|
||||
if ( $rate["{$values['s_type']}_rate_max"] == '*' )
|
||||
if ( $rate["{$values['s_type']}_rate_max"] === '*' )
|
||||
{
|
||||
$max = '*';
|
||||
}
|
||||
@@ -283,12 +283,12 @@ class _FlatRate extends \IPS\Node\Model implements \IPS\nexus\Shipping\Rate
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( !$min and !$max )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$price = array();
|
||||
foreach ( $rate["{$values['s_type']}_rate_price"] as $money )
|
||||
{
|
||||
@@ -320,7 +320,7 @@ class _FlatRate extends \IPS\Node\Model implements \IPS\nexus\Shipping\Rate
|
||||
{
|
||||
unset( $rates[$k] );
|
||||
}
|
||||
|
||||
|
||||
/* Save */
|
||||
$values['rates'] = json_encode( $rates );
|
||||
}
|
||||
@@ -406,8 +406,8 @@ class _FlatRate extends \IPS\Node\Model implements \IPS\nexus\Shipping\Rate
|
||||
{
|
||||
$max = $max[ $currency ];
|
||||
}
|
||||
|
||||
if ( ( $min === '*' or $criteria >= $min ) and ( $max === '*' or $criteria <= $max ) )
|
||||
|
||||
if ( ( $min === '*' or $criteria->compare( new \IPS\Math\Number( number_format( $min, 5, '.', '' ) ) ) !== -1 ) and ( $max === '*' or $criteria->compare( new \IPS\Math\Number( number_format( $max, 5, '.', '' ) ) ) !== 1 ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -430,7 +430,7 @@ class _FlatRate extends \IPS\Node\Model implements \IPS\nexus\Shipping\Rate
|
||||
*
|
||||
* @param array $items Items
|
||||
* @param \IPS\nexus\Invoice|NULL $invoice The invoice
|
||||
* @return The criteria the rased is based on (e.g. if the rate is based on invoice total, will return the invoice total)
|
||||
* @return \IPS\Math\Number The criteria the rased is based on (e.g. if the rate is based on invoice total, will return the invoice total)
|
||||
*/
|
||||
protected function _getCriteria( array $items, \IPS\nexus\Invoice $invoice = NULL )
|
||||
{
|
||||
@@ -443,29 +443,29 @@ class _FlatRate extends \IPS\Node\Model implements \IPS\nexus\Shipping\Rate
|
||||
}
|
||||
else
|
||||
{
|
||||
$criteria = 0;
|
||||
$criteria = new \IPS\Math\Number('0');
|
||||
foreach ( $items as $item )
|
||||
{
|
||||
$criteria += ( $item->price->amount * $item->quantity );
|
||||
$criteria = $criteria->add( $item->linePrice()->amount );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
$criteria = 0;
|
||||
$criteria = new \IPS\Math\Number('0');
|
||||
foreach ( $items as $item )
|
||||
{
|
||||
$criteria += $item->quantity;
|
||||
$criteria = $criteria->add( new \IPS\Math\Number( "{$item->quantity}" ) );
|
||||
}
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
$criteria = 0;
|
||||
$criteria = new \IPS\Math\Number('0');
|
||||
foreach ( $items as $item )
|
||||
{
|
||||
if ( isset( $item->weight ) )
|
||||
{
|
||||
$criteria += ( $item->weight->kilograms * $item->quantity );
|
||||
$criteria = $criteria->add( ( new \IPS\Math\Number( number_format( $item->weight->kilograms, 5, '.', '' ) ) )->multiply( new \IPS\Math\Number( "$item->quantity" ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -484,7 +484,7 @@ class _FlatRate extends \IPS\Node\Model implements \IPS\nexus\Shipping\Rate
|
||||
public function getPrice( array $items, $currency, \IPS\nexus\Invoice $invoice = NULL )
|
||||
{
|
||||
$criteria = $this->_getCriteria( $items, $invoice );
|
||||
|
||||
|
||||
$rates = json_decode( $this->rates, TRUE );
|
||||
foreach ( $rates as $rate )
|
||||
{
|
||||
@@ -498,8 +498,8 @@ class _FlatRate extends \IPS\Node\Model implements \IPS\nexus\Shipping\Rate
|
||||
{
|
||||
$max = $max[ $currency ];
|
||||
}
|
||||
|
||||
if ( ( $min === '*' or $criteria >= $min ) and ( $max === '*' or $criteria <= $max ) )
|
||||
|
||||
if ( ( $min === '*' or $criteria->compare( new \IPS\Math\Number( number_format( $min, 5, '.', '' ) ) ) !== -1 ) and ( $max === '*' or $criteria->compare( new \IPS\Math\Number( number_format( $max, 5, '.', '' ) ) ) !== 1 ) )
|
||||
{
|
||||
return new \IPS\nexus\Money( $rate['price'][ $currency ], $currency );
|
||||
}
|
||||
@@ -541,4 +541,19 @@ class _FlatRate extends \IPS\Node\Model implements \IPS\nexus\Shipping\Rate
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( "nexus_shiprate_de_{$this->id}" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @return array
|
||||
* @apiresponse int id ID number
|
||||
* @apiresponse string name Name
|
||||
*/
|
||||
public function apiOutput()
|
||||
{
|
||||
return array(
|
||||
'id' => $this->id,
|
||||
'name' => \IPS\Member::loggedIn()->language()->addToStack( 'nexus_shiprate_' . $this->id )
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Length Object
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 19 Jun 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -34,7 +34,7 @@ class _Length
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Length in centimetres (naturally we use metres as per le Système international d'unités like good boys)
|
||||
* @brief Length in metres (naturally we use metres as per le Système international d'unités like good boys)
|
||||
*/
|
||||
public $metres = 0;
|
||||
|
||||
@@ -96,6 +96,6 @@ class _Length
|
||||
$unit = static::bestUnit();
|
||||
}
|
||||
|
||||
return round( $this->float( $unit ), $round ) . $unit;
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'length_short_' . $unit, FALSE, array( 'sprintf' => array( round( $this->float( $unit ), $round ) ) ) );
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Shipping Order Model
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 19 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -228,7 +228,7 @@ class _Order extends \IPS\Patterns\ActiveRecord
|
||||
*/
|
||||
public function sendNotification()
|
||||
{
|
||||
$email = \IPS\Email::buildFromTemplate( 'nexus', 'shipment', array( $this ) );
|
||||
$email = \IPS\Email::buildFromTemplate( 'nexus', 'shipment', array( $this ), \IPS\Email::TYPE_TRANSACTIONAL );
|
||||
$email->send( $this->invoice->member );
|
||||
}
|
||||
|
||||
@@ -344,4 +344,46 @@ class _Order extends \IPS\Patterns\ActiveRecord
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @return array
|
||||
* @apiresponse int id ID number
|
||||
* @apiresponse string status Status: 'done' = Shipped; 'pend' = Waiting to be shipped; 'canc' = Canceled
|
||||
* @apiresponse int invoiceId Invoice ID Number
|
||||
* @apiresponse \IPS\nexus\Shipping\FlatRate method The shipment method (may be null if using EasyPost)
|
||||
* @apiresponse object items The items in the shipment and their quantities
|
||||
* @apiresponse datetime requestDate When the shipment was requested
|
||||
* @apiresponse datetime shipDate When the shipment was shipped
|
||||
* @apiresponse \IPS\GeoLocation address The delivery address
|
||||
* @apiresponse string trackingUrl The URL to view tracking information, if available
|
||||
*/
|
||||
public function apiOutput()
|
||||
{
|
||||
$items = array();
|
||||
foreach ( $this->items as $item )
|
||||
{
|
||||
if ( isset( $items[ $item['name'] ] ) )
|
||||
{
|
||||
$items[ $item['name'] ] += $item['quantity'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$items[ $item['name'] ] = $item['quantity'];
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'id' => $this->id,
|
||||
'status' => $this->status,
|
||||
'invoiceId' => $this->invoice->id,
|
||||
'method' => $this->method ? $this->method->apiOutput() : null,
|
||||
'items' => $items,
|
||||
'requestDate' => $this->date->rfc3339(),
|
||||
'shipDate' => $this->shipped_date ? $this->shipped_date->rfc3339() : null,
|
||||
'address' => $this->address()->apiOutput(),
|
||||
'trackingUrl' => $this->trackingUrl() ? ( (string) $this->trackingUrl() ) : null
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Shipping Rate Interface
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 19 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Weight Object
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 13 Feb 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -34,7 +34,7 @@ class _Weight
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Weight in kilograms (naturally we use kilograms as per le Syst�me international d'unitŽs like good boys)
|
||||
* @brief Weight in kilograms (naturally we use kilograms as per le système international d'unités like good boys)
|
||||
*/
|
||||
public $kilograms = 0;
|
||||
|
||||
@@ -95,7 +95,7 @@ class _Weight
|
||||
{
|
||||
$unit = static::bestUnit();
|
||||
}
|
||||
|
||||
return round( $this->float( $unit ), $round ) . $unit;
|
||||
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'weight_short_' . $unit, FALSE, array( 'sprintf' => array( round( $this->float( $unit ), $round ) ) ) );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user