Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1101025
shipping_quote_engine.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Aug 15, 4:15 PM
Size
5 KB
Mime Type
text/x-php
Expires
Sun, Aug 17, 4:15 PM (4 h, 6 m)
Engine
blob
Format
Raw Data
Handle
713070
Attached To
rMINC Modules.In-Commerce
shipping_quote_engine.php
View Options
<?php
/**
* @version $Id: shipping_quote_engine.php 16777 2023-11-22 08:58:04Z alex $
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined
(
'FULL_PATH'
)
or
die
(
'restricted access!'
);
class
ShippingQuoteEngine
extends
kHelper
{
/**
* Quote engine specific properties
*
* @var Array
*/
var
$properties
=
Array
();
public
function
__construct
()
{
parent
::
__construct
();
$this
->
initProperties
();
}
/**
* $params = Array(
* 'AccountLogin' => 'login',
* 'AccountPassword' => 'pass',
* 'carriers' => Array(
* Array(
* 'name' => 'UPS',
* 'account' => '',
* 'invoiced' => '0'
* ),
* Array(
* 'name' => 'DHL',
* 'account' => '',
* 'invoiced' => '0'
* ),
* Array(
* 'name' => 'FDX',
* 'account' => '',
* 'invoiced' => '0'
* ),
* Array(
* 'name' => 'USP',
* 'account' => '',
* 'invoiced' => '0'
* ),
* Array(
* 'name' => 'ARB',
* 'account' => '',
* 'invoiced' => '0'
* ),
* ),
* 'classes' => Array('1DY', '2DY', '3DY', 'GND'),
*
* 'ShipMethod' => 'DRP',
*
* 'orig_name' => 'John%20Smith',
* 'orig_addr1' => '2275%20Union%20Road',
* 'orig_city' => 'Cheektowaga',
* 'orig_state' => 'NY',
* 'orig_postal' => '14227',
* 'orig_country' => 'US',
*
* // this section is required
* 'dest_name' => 'Vasya%20Pupkin',
* 'dest_addr1' => '175%20E.Hawthorn%20pkwy.',
* 'dest_city' => 'Vernon%20Hills',
* 'dest_state' => 'IL',
* 'dest_postal' => '60061',
* 'dest_country' => 'US',
*
* // this section is required
* 'packages' => Array(
* Array(
* 'package_key' => 'package1',
* 'weight' => '50',
* 'weight_unit' => 'LB',
* 'length' => '25',
* 'width' => '15',
* 'height' => '15',
* 'dim_unit' => 'IN',
* 'packaging' => 'BOX',
* 'contents' => 'OTR',
* 'insurance' => '0'
* ),
* Array(
* 'package_key' => 'package2',
* 'weight' => '50',
* 'weight_unit' => 'LB',
* 'length' => '25',
* 'width' => '15',
* 'height' => '15',
* 'dim_unit' => 'IN',
* 'packaging' => 'BOX',
* 'contents' => 'OTR',
* 'insurance' => '0'
* ),
* ),
*
* 'shipment_id' => 1234;
* );
*
*
* Returns:
*
* $quotes = Array(
* 'package1' =>
* Array(
* Array(
* 'id' => 'INTSH_FDX_2DY',
* 'type' => 'FDX',
* ..
* 'amount' => 24.24,
* )
* Array(
* 'type' => 'FDX',
* ..
* 'amount' => 24.24,
* )
* ),
* 'package2' =>
* Array(
* Array(
* 'id' => 'INTSH_FDX_3DY',
* 'type' => 'FDX',
* ..
* 'amount' => 24.24,
* )
* Array(
* 'type' => 'FDX',
* ..
* 'amount' => 24.24,
* )
* ),
* )
*
* @param Array $params
*/
function
GetShippingQuotes
(
$params
)
{
}
/**
* Returns list of shipping types, that can be selected on product editing page
*
* @return Array
*/
function
GetAvailableTypes
()
{
return
Array
();
}
/**
* Returns virtual field names, that will be saved as properties
*
* @return Array
*/
function
GetEngineFields
()
{
return
Array
();
}
/**
* Sends order to shipping quote engine
*
* @param OrdersItem $object
* @param bool $dry_run
* @return Array
*/
function
MakeOrder
(&
$object
,
$dry_run
=
false
)
{
return
Array
();
}
/**
* Loads properties of shipping quote engine
*
* @return void
*/
protected
function
initProperties
()
{
$cache_key
=
'shipping_quote_engines_data[%SqeSerial%]'
;
$cache_value
=
$this
->
Application
->
getCache
(
$cache_key
);
if
(
$cache_value
===
false
)
{
$this
->
Conn
->
nextQueryCachable
=
true
;
$sql
=
'SELECT Properties, FlatSurcharge, PercentSurcharge, LOWER(ClassName) AS SQEKey
FROM '
.
$this
->
Application
->
getUnitOption
(
'sqe'
,
'TableName'
)
.
'
WHERE Status = '
.
STATUS_ACTIVE
;
$cache_value
=
$this
->
Conn
->
Query
(
$sql
,
'SQEKey'
);
foreach
(
$cache_value
as
$sqe_key
=>
$sqe_data
)
{
$properties
=
$sqe_data
[
'Properties'
]
?
unserialize
(
$sqe_data
[
'Properties'
])
:
array
();
$properties
[
'FlatSurcharge'
]
=
$sqe_data
[
'FlatSurcharge'
];
$properties
[
'PercentSurcharge'
]
=
$sqe_data
[
'PercentSurcharge'
];
$cache_value
[
$sqe_key
][
'Properties'
]
=
$properties
;
unset
(
$cache_value
[
$sqe_key
][
'FlatSurcharge'
],
$cache_value
[
$sqe_key
][
'PercentSurcharge'
]);
}
$this
->
Application
->
setCache
(
$cache_key
,
$cache_value
);
}
$sqe_key
=
strtolower
(
get_class
(
$this
));
if
(
array_key_exists
(
$sqe_key
,
$cache_value
)
)
{
$this
->
properties
=
$cache_value
[
$sqe_key
][
'Properties'
];
}
else
{
$this
->
properties
=
array
();
}
}
}
Event Timeline
Log In to Comment