3

I am trying to get the custom session data of Customer in a javascript file. As I am passing 'Magento_Customer/js/customer-data' as dependency in order to retrieve the data.

define(
[
 ......
 'Magento_Customer/js/customer-data'
 .....
],
function (Component,customerData) {
 'use strict';
 return Component.extend({
 defaults: {
 template: 'Mymodule_Company/myTemplate'
 },
 initialize : function(){
 this._super(customerData.getData());
 console.log(customerData.getCustomerInfo());
 }
 });
}
);

I want to get a custom variable just like i set up in my php file :

$this->customerSession->setMyCustomValue("my custom variable");
asked Mar 30, 2017 at 15:28
1
  • Did you mange to get it work? Commented Jul 31, 2019 at 2:23

1 Answer 1

-1

It depends on what you want, if you want like the cart section you could use it in the following way:

customerData.get('cart')();

You could add custom data to the customer data and then retrieve it with like:

customerData.get('sectionData');

More info: http://devdocs.magento.com/guides/v2.2/extension-dev-guide/cache/page-caching/private-content.html

answered Aug 31, 2017 at 9:20

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.