Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add digital stamp to te plugin #452

Merged
merged 13 commits into from
Feb 19, 2019
34 changes: 13 additions & 21 deletions app/code/community/TIG/MyParcel2014/Model/Api/MyParcel.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ class TIG_MyParcel2014_Model_Api_MyParcel extends Varien_Object
const REQUEST_TYPE_RETRIEVE_V2_LABEL = 'pdfs';
const REQUEST_TYPE_GET_LOCATIONS = 'pickup';

/**
* Shipment types
*/
const PACKAGE = 1;
const MAILBOX = 2;
const LETTER = 3;
const DIGITAL_STAMP = 4;

/**
* Consignment types
*/
Expand Down Expand Up @@ -778,9 +770,9 @@ protected function _getConsignmentData(TIG_MyParcel2014_Model_Shipment $myParcel

$data['customs_declaration']['items'][] = array(
'description' => $itemDescription,
'amount' => $WeightData[2],
'weight' => (int)$WeightData[0] * 1000,
'item_value' => array('amount' => $WeightData[3] * 100, 'currency' => 'EUR'),
'amount' => $WeightData['qty'],
'weight' => (int)$WeightData['weight'] * 1000,
'item_value' => array('amount' => $WeightData['price'] * 100, 'currency' => 'EUR'),
'classification' => $customsContentTypeItem,
'country' => Mage::getStoreConfig('general/country/default', $storeId),

Expand All @@ -791,11 +783,11 @@ protected function _getConsignmentData(TIG_MyParcel2014_Model_Shipment $myParcel
}
}
}
$data['customs_declaration']['weight'] = (int)$WeightData[1];
$data['customs_declaration']['weight'] = (int)$WeightData['totalWeight'];

}

if($data['options']['package_type'] == self::DIGITAL_STAMP){
if($data['options']['package_type'] == TIG_MyParcel2014_Model_Shipment::TYPE_DIGITAL_STAMP_NUMBER){
foreach($items as $item) {
RichardPerdaan marked this conversation as resolved.
Show resolved Hide resolved
if($item->getProductType() == 'simple') {
$WeightData = $this->getTotalWeight($totalWeight, $item);
RichardPerdaan marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -804,8 +796,8 @@ protected function _getConsignmentData(TIG_MyParcel2014_Model_Shipment $myParcel
unset($data['options']['weight']);
}

if ($WeightData[1]){
$data['physical_properties']['weight'] = (int)$WeightData[1];
if ($WeightData['totalWeight']){
RichardPerdaan marked this conversation as resolved.
Show resolved Hide resolved
$data['physical_properties']['weight'] = (int)$WeightData['totalWeight'];
}

/**
Expand Down Expand Up @@ -862,7 +854,7 @@ public function getTotalWeight($totalWeight, $item, $isWoldShipment = false) {
$price *= $qty;


return [$weight, $totalWeight, $qty, $price];
return ['weight' => $weight, 'totalWeight' => $totalWeight, 'qty' => $qty, 'price' => $price];


}
Expand All @@ -889,20 +881,20 @@ protected function _getOptionsData(TIG_MyParcel2014_Model_Shipment $myParcelShip
case $myParcelShipment::TYPE_LETTER_BOX:
RichardPerdaan marked this conversation as resolved.
Show resolved Hide resolved
/* Use mailbox only if no option is selected */
if ($helper->shippingMethodIsPakjegemak($myParcelShipment->getOrder()->getShippingMethod())) {
$packageType = self::PACKAGE;
$packageType = $myParcelShipment::TYPE_PACKAGE_NUMBER;
} else {
$packageType = self::MAILBOX;
$packageType = $myParcelShipment::TYPE_MAILBOX_NUMBER;
}
break;
case $myParcelShipment::TYPE_UNPAID:
$packageType = self::LETTER;
$packageType = $myParcelShipment::TYPE_LETTER_NUMBER;
break;
case $myParcelShipment::TYPE_DIGITAL_STAMP:
$packageType = self::DIGITAL_STAMP;
$packageType = $myParcelShipment::TYPE_DIGITAL_STAMP_NUMBER;
break;
case $myParcelShipment::TYPE_NORMAL:
default:
$packageType = self::PACKAGE;
$packageType = $myParcelShipment::TYPE_PACKAGE_NUMBER;
break;
}

Expand Down
8 changes: 8 additions & 0 deletions app/code/community/TIG/MyParcel2014/Model/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ class TIG_MyParcel2014_Model_Shipment extends Mage_Core_Model_Abstract
const TYPE_UNPAID = 'unstamped';
const TYPE_DIGITAL_STAMP = 'digital_stamp';

/**
* Shipment types
*/
const TYPE_PACKAGE_NUMBER = 1;
const TYPE_MAILBOX_NUMBER = 2;
const TYPE_LETTER_NUMBER = 3;
const TYPE_DIGITAL_STAMP_NUMBER = 4;

/** @var TIG_MyParcel2014_Helper_Data $helper */
public $helper;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ if(true == $_isPakjegemak){
<p>
<label for="tig_myparcel_shipment_type" class="normal" ><?php echo $this->__('Shipment type');?></label>
<select id="tig_myparcel_shipment_type" name="tig_myparcel[shipment_type]">
<option value="normal" <?php echo $type == TIG_MyParcel2014_Model_Api_MyParcel::PACKAGE ? 'selected="selected"' : '';?>><?php echo $this->__('Normal'); ?></option>
<option value="normal" <?php echo $type == TIG_MyParcel2014_Model_Shipment::TYPE_PACKAGE_NUMBER ? 'selected="selected"' : '';?>><?php echo $this->__('Normal'); ?></option>
<?php if ($this->getDestinationCountry() == 'NL'): ?>
<option value="letter_box" <?php echo $_disabled;?> <?php echo $type == TIG_MyParcel2014_Model_Api_MyParcel::MAILBOX ? 'selected="selected"' : '';?>><?php echo $this->__('Letter box'); ?></option>
<option value="digital_stamp" <?php echo $_disabled;?> <?php echo $type == TIG_MyParcel2014_Model_Api_MyParcel::DIGITAL_STAMP ? 'selected="selected"' : '';?>><?php echo $this->__('Digital Stamp'); ?></option>
<option value="letter_box" <?php echo $_disabled;?> <?php echo $type == TIG_MyParcel2014_Model_Shipment::TYPE_MAILBOX_NUMBER ? 'selected="selected"' : '';?>><?php echo $this->__('Letter box'); ?></option>
<option value="digital_stamp" <?php echo $_disabled;?> <?php echo $type == TIG_MyParcel2014_Model_Shipment::TYPE_DIGITAL_STAMP_NUMBER ? 'selected="selected"' : '';?>><?php echo $this->__('Digital Stamp'); ?></option>
<?php endif; ?>
<option value="unstamped" <?php echo $_disabled;?> ><?php echo $this->__('Unpaid'); ?></option>
</select>
Expand Down