owebia / magento2-module-advanced-shipping

Other
90 stars 28 forks source link

cannot used custom customer attribute. #30

Closed shihoradhruvi closed 6 years ago

shihoradhruvi commented 7 years ago

Hello,

I want to use custom attribute of customer in condition but wont be able to use that. I tried using email attribute and that works but custom created attribute does not.

My configuration file include code as below,

addMethod('local_pickup', [ 'title' => "Local Pickup", 'description' => "Local Pickup", 'enabled' => $customer->enable_localpickup == '1', 'price' => 0 ]);

this does not work for me.

Can you please help me?

owebia commented 7 years ago

Hi, Sorry not having responded before. How do you have added the custom customer attribute?

Best Regards, A.L.

owebia commented 6 years ago

Here is some informations about custom customer attributes.

It seems that custom customer attributes are not loaded in customer object data by Magento.

To access to a custom customer attribute, you should use the syntax below:

addMethod('local_pickup', [
    'title' => "Local Pickup",
    'description' => "Local Pickup",
    'enabled' => $customer->getCustomAttribute('enable_localpickup')->value == '1',
    'price' => 0,
]);

A.L.