1

I would need to hide SHIPPER_ACCOUNT_NUMBER on FedEx shipping label. FedEx support told me I had to set this in the module, that their API is able to hide some elements.

They gave me :

<CustomerSpecifiedDetail>
<MaskedData>CUSTOMS_VALUE</MaskedData>
<MaskedData>DUTIES_AND_TAXES_PAYOR_ACCOUNT_NUMBER</MaskedData>
<MaskedData>SHIPPER_ACCOUNT_NUMBER</MaskedData>
<MaskedData>TRANSPORTATION_CHARGES_PAYOR_ACCOUNT_NUMBER</MaskedData>
</CustomerSpecifiedDetail>
</LabelSpecification>

But I can't find which file I have to edit.

I found

SHIPPER_ACCOUNT_NUMBER

in

vendor/magento/module-fedex/etc/wsdl/ShipService_v9.wsdl

and

vendor/magento/module-fedex/etc/wsdl/ShipService_v10.wsdl

:

<xs:simpleType name="LabelMaskableDataType">
    <xs:annotation>
        <xs:documentation>Names for data elements / areas which may be suppressed from printing on labels.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
        <xs:enumeration value="CUSTOMS_VALUE"/>
        <xs:enumeration value="DUTIES_AND_TAXES_PAYOR_ACCOUNT_NUMBER"/>
        <xs:enumeration value="SHIPPER_ACCOUNT_NUMBER"/>
        <xs:enumeration value="TERMS_AND_CONDITIONS"/>
        <xs:enumeration value="TRANSPORTATION_CHARGES_PAYOR_ACCOUNT_NUMBER"/>
    </xs:restriction>
</xs:simpleType>

So module should be able to hide this also, but I did not find any options in administration.

I would also like to have this as an override if possible, so that I could update Magento without having to write a hack every time.

Any help would be appreciated

3

The method currently building the request is Magento\Fedex\Model\Carrier::_formShipmentRequest. You'll likely need to insert a preference for the Carrier class because the method you need to update and it's sole caller, Magento\Fedex\Model\Carrier::_doShipmentRequest, are protected. Drop code similar to the examples below in a custom module and any new shipping labels create should have the data masked. This will not update existing labels since the label is created and stored with the shipment data when it is created.

Vendor/Module/Model/Fedex/Carrier.php

<?php

namespace Vendor\Module\Model\Fedex;

class Carrier extends \Magento\Fedex\Model\Carrier
{
    protected function _formShipmentRequest(
        \Magento\Framework\DataObject $request
    ) {
        $result = parent::_formShipmentRequest($request);

        if (!isset($result['RequestedShipment']['LabelSpecification'])) {
            return $result;
        }

        $result['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['MaskedData'] = [
            'CUSTOMS_VALUE',
            'DUTIES_AND_TAXES_PAYOR_ACCOUNT_NUMBER',
            'SHIPPER_ACCOUNT_NUMBER',
            'TRANSPORTATION_CHARGES_PAYOR_ACCOUNT_NUMBER',
        ];

        return $result;
    }
}

Vendor/Module/etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Fedex\Model\Carrier" type="Vendor\Module\Model\Fedex\Carrier" />
</config>
  • Thanks for the answer and the effort, I added the module, and will get back to you on next orders to tell you how it's working. – David Sep 27 '17 at 13:41
  • It seems like the shipping can not be created anymore after the adding of the module. – David Sep 28 '17 at 10:00
  • Sorry my bad, I was also working in parallel on the adding of tax_amount column for orders and invoice grids, and it appears it was blocking the shipping label creation.. Magento dev can be so pernickety sometimes.. Your solution works great, thanks a lot !!! – David Sep 28 '17 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.