My code works on my dev machine and not on production, sadly. (really sadly).
The module is about adding a dropdown on checkout page on the ship address page.
Here is my 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">
<type name="Magento\Checkout\Model\ShippingInformationManagement">
<plugin name="magasin_address_save_plugin" type="Vendor\MagasinSelector\Plugin\MagasinOrderPlugin" sortOrder="10"/>
</type>
<type name="Magento\Sales\Api\OrderRepositoryInterface">
<plugin name="get_order_magasin_id" type="Vendor\MagasinSelector\Plugin\OrderGet"/>
</type>
<type name="Magento\Checkout\Block\Checkout\LayoutProcessor">
<plugin name="magasin_selector" type="Vendor\MagasinSelector\Plugin\MagasinPlugin" sortOrder="100" />
</type>
</config>
MagasinPlugin.php :
<?phpnamespace HexaPlus\MagasinSelector\Plugin;
use Magento\Checkout\Block\Checkout\LayoutProcessor;
use MageClass\ClickAndCollect\Model\Store;
class MagasinPlugin
{
public function afterProcess(LayoutProcessor $subject, $jsLayout) {
$customAttributeCode = 'magasin_id'; $customField = [
'component' => 'Magento_Ui/js/form/element/select',
'config' => [
'customScope' => 'shippingAddress.custom_attributes',
'template' => 'ui/form/field',
'elementTmpl' => 'ui/form/element/select',
'id' => 'drop-down2',
],
'dataScope' => 'shippingAddress.custom_attributes.magasin_id',
'label' => 'Sélectionner Votre magasin conseil (cela ne sera pas forcément votre lieu de livraison)',
'provider' => 'checkoutProvider',
'visible' => true,
'validation' => ['required-entry' => true],
'sortOrder' => 150,
'id' => 'drop-down2',
'options' => $options
]; $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['shippingAddress']['children']['shipping-address-fieldset']['children'][$customAttributeCode] = $customField;
return $jsLayout;
}
}
?>
(I removed the $options part). It works on dev, same version 2.2.6 it doesnt work on prod ! I have no idea why.
Most interessting part : If I copy & paste the .di xml inside one other module, it works..
I tried everything : removed generation folder. cache clean. di:compile..
What I am doing wrong ?
Thanks you