Skip to content

Commit

Permalink
Merge branch 'develop' of ssh://git@github.com/exponentcms/exponent-c…
Browse files Browse the repository at this point in the history
…ms into develop
  • Loading branch information
freddirkse committed Jul 13, 2011
2 parents fb39a74 + f0eb74b commit 1e8ebec
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 8 deletions.
12 changes: 12 additions & 0 deletions framework/datatypes/ecomconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ public static function getConfig($configname) {
return null;
}
}

public static function splitConfigUpCharge($upcharge = array(), $type = 'region') {
$upchargeRate = array();
foreach($upcharge as $key => $item) {
$tmp = explode('_', $key);
if($tmp[0] == $type) {
$upchargeRate[$tmp[1]] = $item;
}
}

return $upchargeRate;
}
}

?>
4 changes: 4 additions & 0 deletions framework/modules/administration/menus/ecomm.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
array(
'text'=>"Address/Geo Settings",
'url'=>makeLink(array('controller'=>'address','action'=>'manage')),
),
array(
'text'=>"Manage Up Charge Rate",
'url'=>makeLink(array('controller'=>'ecomconfig','action'=>'manage_upcharge')),
),
array(
'text'=>"Manage Tax Classes",
Expand Down
40 changes: 39 additions & 1 deletion framework/modules/ecommerce/controllers/ecomconfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,45 @@ function configure() {
$regions = $gr->find('all');

assign_to_template(array('config'=>$this->config, 'pullable_modules'=>$pullable_modules, 'views'=>$views,'countries'=>$countries, 'regions'=>$regions));
}
}


/*****************************************************************/
/*************** Upcharge Rate *******************************/
/*****************************************************************/

function manage_upcharge() {
$this->loc->src = "@globalstoresettings";
$config = new expConfig($this->loc);
$this->config = $config->config;

$gc = new geoCountry();
$countries = $gc->find('all');

$gr = new geoRegion();
$regions = $gr->find('all',null,'rank asc,name asc');
assign_to_template(array('countries'=>$countries, 'regions'=>$regions, 'upcharge'=>$this->config['upcharge']));
}

function update_upcharge() {

$this->loc->src = "@globalstoresettings";
$config = new expConfig($this->loc);
$this->config = $config->config;

//This will make sure that only the country or region that given a rate value will be saved in the db
$upcharge = array();
foreach($this->params['upcharge'] as $key => $item) {
if(!empty($item)) {
$upcharge[$key] = $item;
}
}
$this->config['upcharge'] = $upcharge;

$config->update(array('config'=>$this->config));
flash('message', 'Configuration updated');
expHistory::back();
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,21 @@ public function getRates($order) {

//if certain states, add $$ from config
$currentMethod = $order->getCurrentShippingMethod(); //third created shipping method

//Get the config and parse to get the states/regions only
$upcharge = ecomconfig::getConfig('upcharge');
$stateUpcharge = ecomconfig::splitConfigUpCharge($upcharge, 'region');

//2 - alaska
//21 - hawaii
//52 - PuertoRico
$stateUpcharge = array('2','21','52');

$rates = array();
if(!empty($c)) {
// $stateUpcharge = array('2','21','52');
$rates = array();
if(!empty($c)) {
for($i = 0; $i < count($c); $i++) {

if (in_array($currentMethod->state, $stateUpcharge)) {
$c[$i] += 1.50; $c[$i] += 1.50;
if (array_key_exists($currentMethod->state, $stateUpcharge)) {
$c[$i] += $stateUpcharge[$currentMethod->state]; // $c[$i] += $stateUpcharge[$currentMethod->state]; Commented this though i'm not sure if this is done intentionally
}
if($i > 9) $rates[($i+1)] = array('id' => 0 . ($i+1), 'title' => $this->shippingspeeds[$i]->speed, 'cost' => $c[$i]);
else $rates[0 . ($i+1)] = array('id' => 0 . ($i+1), 'title' => @$this->shippingspeeds[$i]->speed, 'cost' => $c[$i]);
Expand Down
2 changes: 1 addition & 1 deletion phpdoc.ini
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ defaultpackagename = Exponent-CMS
;; where should the documentation be written?
;; legal values: a legal path
;target = /home/cellog/output
target = ../exponent-cms-docs
target = ../exponent-api

;; Which files should be parsed out as special documentation files, such as README,
;; INSTALL and CHANGELOG? This overrides the default files found in
Expand Down

0 comments on commit 1e8ebec

Please sign in to comment.