Skip to content

Commit

Permalink
exclude boxpacker helper on PHP installs <=5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
damanic committed Mar 7, 2018
1 parent ed3b01f commit 606ea55
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion classes/shop_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ class Shop_Module extends Core_ModuleBase
private static $catalog_version_update = false;

public function __construct(){
require_once( PATH_APP . '/modules/shop/vendor/autoload.php' );
if (version_compare(phpversion(), '5.4.0', '>=')) {
//add helpers (boxpacker)
require_once( PATH_APP . '/modules/shop/vendor/autoload.php' );
}
}

/**
Expand Down
9 changes: 9 additions & 0 deletions helpers/shop_boxpacker.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<?php
/*
* This helper requires PHP v5.4+
*/
if (version_compare(phpversion(), '5.4.0', '<')) {
return;
}

use DVDoug\BoxPacker\Packer as BockPacker;
use DVDoug\BoxPacker\Box as BoxPackerBox;
Expand All @@ -12,6 +18,9 @@ class Shop_BoxPacker {
protected $unpackable_items = array();

public function __construct() {
if (version_compare(phpversion(), '5.4.0', '<')) {
throw new Phpr_ApplicationException('Error: Shop_Boxpacker requires PHP >= 5.4');
}
$this->shipping_params = Shop_ShippingParams::get();
$this->weights_in_kg = ( $this->shipping_params->weight_unit == 'KGS' );
$this->dimensions_in_cm = ( $this->shipping_params->dimension_unit == 'CM' );
Expand Down

0 comments on commit 606ea55

Please sign in to comment.