This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
338 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,22 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
MAGENTO_ROOT="/magento" | ||
PHP="/usr/local/bin/php" | ||
COMPOSER="$PHP /usr/local/bin/composer" | ||
set -e # Exit on error | ||
|
||
MODULE_NAME="Meanbee_RoyalMail" | ||
COMPOSER_NAME="meanbee/module-royalmail" | ||
|
||
MAGENTO_TOOL="magento-command" | ||
# Install Magento 2 if necessary | ||
magento-installer | ||
|
||
cd $MAGENTO_ROOT | ||
|
||
# This is required because Magento doesn't support the path type in composer | ||
# this is a hack. | ||
|
||
$COMPOSER config repositories.meanbee_royalmail path /src/src | ||
|
||
$COMPOSER require "$COMPOSER_NAME" "*@dev" | ||
|
||
# Required due to us using the "path" type for the repository | ||
$COMPOSER require "composer/composer" "1.0.0-alpha11 as 1.0.0-alpha10" | ||
|
||
$MAGENTO_TOOL module:enable $MODULE_NAME | ||
|
||
$MAGENTO_TOOL setup:upgrade | ||
# Add the extension via Composer | ||
composer config repositories.meanbee_royalmail '{"type": "path", "url": "/src/src", "options": {"symlink": true}}' | ||
|
||
$MAGENTO_TOOL setup:static-content:deploy | ||
composer require "meanbee/module-royalmail" "@dev" | ||
|
||
$MAGENTO_TOOL cache:flush | ||
# Workaround for Magento only allowing template paths within the install root | ||
ln -s /src $MAGENTO_ROOT/src/src | ||
|
||
$MAGENTO_TOOL deploy:mode:set developer | ||
# Enable the extension and run migrations | ||
magento-command module:enable Meanbee_Royalmail | ||
magento-command setup:upgrade | ||
magento-command setup:static-content:deploy | ||
magento-command cache:flush |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,230 @@ | ||
<?php | ||
|
||
namespace Meanbee\MagentoRoyalmail\Model; | ||
|
||
/** | ||
* Class Method | ||
*/ | ||
class Method | ||
{ | ||
/** | ||
* The ID of the method rule. | ||
* | ||
* @var string | ||
*/ | ||
protected $id; | ||
|
||
|
||
/** | ||
* The shipping code name of the method | ||
* | ||
* @var string | ||
*/ | ||
protected $code; | ||
|
||
/** | ||
* The clean shipping method name of the shipping method | ||
* | ||
* @var string | ||
*/ | ||
protected $name; | ||
|
||
/** | ||
* The country code of the method | ||
* | ||
* @var string | ||
*/ | ||
protected $countryCode; | ||
|
||
/** | ||
* Price of method | ||
* | ||
* @var string | ||
*/ | ||
protected $price; | ||
|
||
/** | ||
* Maximum value of package that is insured | ||
* | ||
* @var string | ||
*/ | ||
protected $insuranceValue; | ||
|
||
/** | ||
* The minimum weight the shipping method can accommodate | ||
* | ||
* @var string | ||
*/ | ||
protected $minimumWeight; | ||
|
||
/** | ||
* The maximum weight the shipping method can accommodate | ||
* | ||
* @var string | ||
*/ | ||
protected $maximumWeight; | ||
|
||
/** | ||
* The parcel size, only applies to small and medium parcels | ||
* | ||
* @var string | ||
*/ | ||
protected $size; | ||
|
||
/** | ||
* Dictionary to replace strings within method codes. | ||
* Without shortening, method codes are too long and Magento rejects order. | ||
* | ||
* @var $methodDitionary | ||
*/ | ||
protected static $methodDictionary = array( | ||
'economy' => 'eco', | ||
'express' => 'xp', | ||
'firstclass' => '1st', | ||
'international' => 'i11l', | ||
'large' => 'lg', | ||
'letter' => 'ltr', | ||
'medium' => 'med', | ||
'parcelforce' => 'pf', | ||
'parcel' => 'prcl', | ||
'saturday' => 'sat', | ||
'standard' => 'std', | ||
'secondclass' => '2nd', | ||
'signedfor' => 'signed', | ||
'small' => 'sm', | ||
'specialdelivery' => 'special', | ||
'trackedandsigned' => 'tracksign', | ||
'trackedsigned' => 'tracksign', | ||
'worldwide' => 'ww', | ||
); | ||
|
||
/** | ||
* Method constructor. | ||
* | ||
* @param string $id - Method unique identifier | ||
* @param string $code - Method code | ||
* @param string $name - Method label | ||
* @param string $countryCode - Country code of method | ||
* @param string $price - Price of method | ||
* @param string $insuranceValue - Insurance value of method | ||
* @param string $minimumWeight - Minimum weight the method can have | ||
* @param string $maximumWeight - Maximum weight the method can have | ||
* @param null $size - Parcel size, only applies to sm and md parcels | ||
*/ | ||
public function __construct( | ||
$id, | ||
$code, | ||
$name, | ||
$countryCode = null, | ||
$price = null, | ||
$insuranceValue = null, | ||
$minimumWeight = null, | ||
$maximumWeight = null, | ||
$size = null | ||
) { | ||
$this->id = $id; | ||
$this->code = str_replace( | ||
array_keys(self::$methodDictionary), | ||
array_values(self::$methodDictionary), | ||
$code | ||
); | ||
$this->name = $name; | ||
$this->countryCode = $countryCode; | ||
$this->price = $price; | ||
$this->insuranceValue = $insuranceValue; | ||
$this->minimumWeight = $minimumWeight; | ||
$this->maximumWeight = $maximumWeight; | ||
$this->size = $size; | ||
} | ||
|
||
/** | ||
* The unique ID of a method | ||
* | ||
* @return string | ||
*/ | ||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* The method code | ||
* | ||
* @return string | ||
*/ | ||
public function getCode() | ||
{ | ||
return $this->code; | ||
} | ||
|
||
/** | ||
* The clean shipping method name of the shipping method | ||
* | ||
* @return string | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* The country code of the method | ||
* | ||
* @return string | ||
*/ | ||
public function getCountryCode() | ||
{ | ||
return $this->countryCode; | ||
} | ||
|
||
/** | ||
* Price of method | ||
* | ||
* @return string | ||
*/ | ||
public function getPrice() | ||
{ | ||
return $this->price; | ||
} | ||
|
||
/** | ||
* Maximum value of package that is insured | ||
* | ||
* @return string | ||
*/ | ||
public function getInsuranceValue() | ||
{ | ||
return $this->insuranceValue; | ||
} | ||
|
||
/** | ||
* The minimum weight the shipping method can accommodate | ||
* | ||
* @return string | ||
*/ | ||
public function getMinimumWeight() | ||
{ | ||
return $this->minimumWeight; | ||
} | ||
|
||
/** | ||
* The maximum weight the shipping method can accommodate | ||
* | ||
* @return string | ||
*/ | ||
public function getMaximumWeight() | ||
{ | ||
return $this->maximumWeight; | ||
} | ||
|
||
/** | ||
* The parcel size, only applies to small and medium parcels | ||
* | ||
* @return string | ||
*/ | ||
public function getSize() | ||
{ | ||
return $this->size; | ||
} | ||
|
||
} |
Oops, something went wrong.