Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Unitofmeasure.php
Go to the documentation of this file.
1 <?php
7 
13 
17 class Unitofmeasure extends Field
18 {
24  protected $carrierHelper;
25 
29  protected $carrierDhl;
30 
37  public function __construct(
38  Context $context,
39  Model\Carrier $carrierDhl,
40  Helper\Carrier $carrierHelper,
41  array $data = []
42  ) {
43  $this->carrierDhl = $carrierDhl;
44  $this->carrierHelper = $carrierHelper;
45  parent::__construct($context, $data);
46  }
47 
53  public function _construct()
54  {
55  parent::_construct();
56 
57  $this->setInch($this->carrierDhl->getCode('unit_of_dimension_cut', 'I'));
58  $this->setCm($this->carrierDhl->getCode('unit_of_dimension_cut', 'C'));
59 
60  $this->setHeight($this->carrierDhl->getCode('dimensions', 'height'));
61  $this->setDepth($this->carrierDhl->getCode('dimensions', 'depth'));
62  $this->setWidth($this->carrierDhl->getCode('dimensions', 'width'));
63 
64  $kgWeight = 70;
65 
66  $this->setDivideOrderWeightNoteKg(
67  __(
68  'Select this to allow DHL to optimize shipping charges by splitting the order if it exceeds %1 %2.',
69  $kgWeight,
70  'kg'
71  )
72  );
73 
74  $convertedWeight = $this->carrierHelper->convertMeasureWeight(
75  $kgWeight,
78  );
79  $weight = sprintf('%.3f', $convertedWeight);
80 
81  $this->setDivideOrderWeightNoteLbp(
82  __(
83  'Select this to allow DHL to optimize shipping charges by splitting the order if it exceeds %1 %2.',
84  $weight,
85  'pounds'
86  )
87  );
88 
89  $this->setTemplate('Magento_Dhl::unitofmeasure.phtml');
90  }
91 
99  {
100  return parent::_getElementHtml($element) . $this->_toHtml();
101  }
102 }
__construct(Context $context, Model\Carrier $carrierDhl, Helper\Carrier $carrierHelper, array $data=[])
_getElementHtml(AbstractElement $element)
__()
Definition: __.php:13
$element
Definition: element.phtml:12