-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPurolatorPlugin.php
67 lines (58 loc) · 1.82 KB
/
PurolatorPlugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
namespace Craft;
class PurolatorPlugin extends BasePlugin
{
function getName()
{
return 'Purolator';
}
function getVersion()
{
return '2.0';
}
function getDeveloper()
{
return 'Globalia';
}
function getDeveloperUrl()
{
return 'http://www.globalia.ca';
}
public function getSettingsHtml()
{
return craft()->templates->render('purolator/settings', array(
'settings' => $this->getSettings()
));
}
protected function defineSettings()
{
return array(
'developmentKey' => array(AttributeType::String),
'developmentKeyPassword' => array(AttributeType::String),
'developmentCourierAccountNumber' => array(AttributeType::String),
'productionKey' => array(AttributeType::String),
'productionKeyPassword' => array(AttributeType::String),
'courierAccountNumber' => array(AttributeType::String),
'testMode' => array(AttributeType::Bool),
'senderPostalCode' => array(AttributeType::String)
);
}
public function init()
{
require_once CRAFT_PLUGINS_PATH . '/purolator/vendor/autoload.php';
}
public function commerce_registerShippingMethods()
{
$shippingMethods = craft()->purolator_estimate->shippingMethods;
$models = array();
foreach($shippingMethods as $code => $name){
$methodModel = new Purolator_ShippingMethodModel();
$methodModel->setAttributes(array(
'code' => $code,
'name' => $name
));
$models[] = $methodModel;
}
return $models;
}
}