Magento 2: How to override core js module price-bundle.jsMagento2: How can I override core js module...

What are these green text/line displays shown during the livestream of Crew Dragon's approach to dock with the ISS?

Why can I easily sing or whistle a tune I've just heard, but not as easily reproduce it on an instrument?

Why does the DC-9-80 have this cusp in its fuselage?

What is the wife of a henpecked husband called?

How do Japanese speakers determine the implied topic when none has been mentioned?

Is Draco canonically good-looking?

Why didn't Eru and/or the Valar intervene when Sauron corrupted Númenor?

How to define a macro with multiple optional parameters?

Why is this code uniquely decodable?

How to acknowledge an embarrassing job interview, now that I work directly with the interviewer?

Can I become debt free or should I file for bankruptcy? How do I manage my debt and finances?

Is there a way to help users from having to clicking emails twice before logging into a new sandbox

How to push a box with physics engine by another object?

Auto Insert date into Notepad

Can chords be played on the flute?

Am I a Rude Number?

Obtaining a matrix of complex values from associations giving the real and imaginary parts of each element?

How would an AI self awareness kill switch work?

How can I improve my fireworks photography?

4 Spheres all touching each other??

Wanted: 5.25 floppy to usb adapter

Finding the number of integers that are a square and a cube at the same time

How to properly claim credit for peer review?

Counting monomials in skew-symmetric+diagonal matrices



Magento 2: How to override core js module price-bundle.js


Magento2: How can I override core js module price-box.jsMagento 2 - Overriding a built in magento widget - configurable products dropdownMagento 2 Replace a default JSHow to properly override a core JS file in Magento2Magento 2.1: how to remove argument and/or argument item from block?overriding/extending price-options.js does not workOverride Magento 2 JS file via requirejs-config.js not workingOverriding magento core scripts.js file: Magento 2Override Magento 2 core JS file Without affecting core functioniltiesHow to override price-utils.js specific method?Override form.phtml in own moduleHow to move product.price.render.bundle.customization from bundle.summary to product.info.price in Magento 2













1















I am attempting to override the _onQtyFieldChanged event in the mage.priceBundle widget in the module-bundle/view/base/web/js/price-bundle.js file.



I am referencing the Magento dev docs (http://devdocs.magento.com/guides/v2.0/javascript-dev-guide/javascript/custom_js.html) and this Magento StackExchange question (Magento2: How can I override core js module price-box.js), but I can't manage to get my custom _onQtyFieldChanged event method to execute. As of now I only have a console.log statement in that method.



A little background:
My custom price-bundle.js file is found in Endertech/BundleExtended/view/base/web/js directory.
My requirejs-config.js is in Endertech/BundleExtended/view/frontend.



requirejs-config.js:



var config = {
map: {
"*": {
priceBundle: 'Endertech_BundleExtended/js/price-bundle',
'Magento_Bundle/js/price-bundle': 'Endertech_BundleExtended/js/price-bundle'
}
}

};


Endertech/BundleExtended/view/base/web/js/price-bundle.js:



define([
'jquery',
'underscore',
'mage/template',
'priceUtils',
'priceBox',
'priceBundle',
], function ($, _, mageTemplate, utils) {
'use strict';

$.widget('Endertech.priceBundle', $.mage.priceBundle, {

_onQtyFieldChanged: function onQtyFieldChanged(event) {
console.log("Endertech Module");
var field = $(event.target),
optionInstance,
optionConfig;

if (field.data('optionId') && field.data('optionValueId')) {
optionInstance = field.data('option');
optionConfig = this.options.optionConfig
.options[field.data('optionId')]
.selections[field.data('optionValueId')];
optionConfig.qty = field.val();

optionInstance.trigger('change');
}
}
});

return $.Endertech.priceBundle;

});


EDIT:



So I realized that probably the issue I am coming across is the fact that the widget method I am trying to modify is a private method in module-bundle/view/base/web/js/price-bundle.js. Which is the reason why I can't override it or extend it. I am not sure if there is a way to get around this or a different approach I need to take to this issue that I don't know about.



Any help and suggestions are greatly appreciated.










share|improve this question




















  • 1





    We may have architecture for this. Checking.

    – benmarks
    Jun 7 '16 at 16:06






  • 2





    Confirmed, we have JavaScript mixins which can do this. You'll get a response soon.

    – benmarks
    Jun 8 '16 at 15:34











  • @benmarks thank you so much for looking into my issue, I had also thought about JavaScript mixins, but the first time I attempted it I was having issues accessing some of the $.mage.priceBundle parameters and methods.

    – Noemi Quezada
    Jun 8 '16 at 21:26











  • @NoemiQuezada Please mark the correct answer

    – Stevie G
    Jan 13 '17 at 15:00











  • Hi @NoemiQuezada have you got solution for it. please share the piece of code if you find any solution regrading it

    – Himanshu
    54 mins ago
















1















I am attempting to override the _onQtyFieldChanged event in the mage.priceBundle widget in the module-bundle/view/base/web/js/price-bundle.js file.



I am referencing the Magento dev docs (http://devdocs.magento.com/guides/v2.0/javascript-dev-guide/javascript/custom_js.html) and this Magento StackExchange question (Magento2: How can I override core js module price-box.js), but I can't manage to get my custom _onQtyFieldChanged event method to execute. As of now I only have a console.log statement in that method.



A little background:
My custom price-bundle.js file is found in Endertech/BundleExtended/view/base/web/js directory.
My requirejs-config.js is in Endertech/BundleExtended/view/frontend.



requirejs-config.js:



var config = {
map: {
"*": {
priceBundle: 'Endertech_BundleExtended/js/price-bundle',
'Magento_Bundle/js/price-bundle': 'Endertech_BundleExtended/js/price-bundle'
}
}

};


Endertech/BundleExtended/view/base/web/js/price-bundle.js:



define([
'jquery',
'underscore',
'mage/template',
'priceUtils',
'priceBox',
'priceBundle',
], function ($, _, mageTemplate, utils) {
'use strict';

$.widget('Endertech.priceBundle', $.mage.priceBundle, {

_onQtyFieldChanged: function onQtyFieldChanged(event) {
console.log("Endertech Module");
var field = $(event.target),
optionInstance,
optionConfig;

if (field.data('optionId') && field.data('optionValueId')) {
optionInstance = field.data('option');
optionConfig = this.options.optionConfig
.options[field.data('optionId')]
.selections[field.data('optionValueId')];
optionConfig.qty = field.val();

optionInstance.trigger('change');
}
}
});

return $.Endertech.priceBundle;

});


EDIT:



So I realized that probably the issue I am coming across is the fact that the widget method I am trying to modify is a private method in module-bundle/view/base/web/js/price-bundle.js. Which is the reason why I can't override it or extend it. I am not sure if there is a way to get around this or a different approach I need to take to this issue that I don't know about.



Any help and suggestions are greatly appreciated.










share|improve this question




















  • 1





    We may have architecture for this. Checking.

    – benmarks
    Jun 7 '16 at 16:06






  • 2





    Confirmed, we have JavaScript mixins which can do this. You'll get a response soon.

    – benmarks
    Jun 8 '16 at 15:34











  • @benmarks thank you so much for looking into my issue, I had also thought about JavaScript mixins, but the first time I attempted it I was having issues accessing some of the $.mage.priceBundle parameters and methods.

    – Noemi Quezada
    Jun 8 '16 at 21:26











  • @NoemiQuezada Please mark the correct answer

    – Stevie G
    Jan 13 '17 at 15:00











  • Hi @NoemiQuezada have you got solution for it. please share the piece of code if you find any solution regrading it

    – Himanshu
    54 mins ago














1












1








1


1






I am attempting to override the _onQtyFieldChanged event in the mage.priceBundle widget in the module-bundle/view/base/web/js/price-bundle.js file.



I am referencing the Magento dev docs (http://devdocs.magento.com/guides/v2.0/javascript-dev-guide/javascript/custom_js.html) and this Magento StackExchange question (Magento2: How can I override core js module price-box.js), but I can't manage to get my custom _onQtyFieldChanged event method to execute. As of now I only have a console.log statement in that method.



A little background:
My custom price-bundle.js file is found in Endertech/BundleExtended/view/base/web/js directory.
My requirejs-config.js is in Endertech/BundleExtended/view/frontend.



requirejs-config.js:



var config = {
map: {
"*": {
priceBundle: 'Endertech_BundleExtended/js/price-bundle',
'Magento_Bundle/js/price-bundle': 'Endertech_BundleExtended/js/price-bundle'
}
}

};


Endertech/BundleExtended/view/base/web/js/price-bundle.js:



define([
'jquery',
'underscore',
'mage/template',
'priceUtils',
'priceBox',
'priceBundle',
], function ($, _, mageTemplate, utils) {
'use strict';

$.widget('Endertech.priceBundle', $.mage.priceBundle, {

_onQtyFieldChanged: function onQtyFieldChanged(event) {
console.log("Endertech Module");
var field = $(event.target),
optionInstance,
optionConfig;

if (field.data('optionId') && field.data('optionValueId')) {
optionInstance = field.data('option');
optionConfig = this.options.optionConfig
.options[field.data('optionId')]
.selections[field.data('optionValueId')];
optionConfig.qty = field.val();

optionInstance.trigger('change');
}
}
});

return $.Endertech.priceBundle;

});


EDIT:



So I realized that probably the issue I am coming across is the fact that the widget method I am trying to modify is a private method in module-bundle/view/base/web/js/price-bundle.js. Which is the reason why I can't override it or extend it. I am not sure if there is a way to get around this or a different approach I need to take to this issue that I don't know about.



Any help and suggestions are greatly appreciated.










share|improve this question
















I am attempting to override the _onQtyFieldChanged event in the mage.priceBundle widget in the module-bundle/view/base/web/js/price-bundle.js file.



I am referencing the Magento dev docs (http://devdocs.magento.com/guides/v2.0/javascript-dev-guide/javascript/custom_js.html) and this Magento StackExchange question (Magento2: How can I override core js module price-box.js), but I can't manage to get my custom _onQtyFieldChanged event method to execute. As of now I only have a console.log statement in that method.



A little background:
My custom price-bundle.js file is found in Endertech/BundleExtended/view/base/web/js directory.
My requirejs-config.js is in Endertech/BundleExtended/view/frontend.



requirejs-config.js:



var config = {
map: {
"*": {
priceBundle: 'Endertech_BundleExtended/js/price-bundle',
'Magento_Bundle/js/price-bundle': 'Endertech_BundleExtended/js/price-bundle'
}
}

};


Endertech/BundleExtended/view/base/web/js/price-bundle.js:



define([
'jquery',
'underscore',
'mage/template',
'priceUtils',
'priceBox',
'priceBundle',
], function ($, _, mageTemplate, utils) {
'use strict';

$.widget('Endertech.priceBundle', $.mage.priceBundle, {

_onQtyFieldChanged: function onQtyFieldChanged(event) {
console.log("Endertech Module");
var field = $(event.target),
optionInstance,
optionConfig;

if (field.data('optionId') && field.data('optionValueId')) {
optionInstance = field.data('option');
optionConfig = this.options.optionConfig
.options[field.data('optionId')]
.selections[field.data('optionValueId')];
optionConfig.qty = field.val();

optionInstance.trigger('change');
}
}
});

return $.Endertech.priceBundle;

});


EDIT:



So I realized that probably the issue I am coming across is the fact that the widget method I am trying to modify is a private method in module-bundle/view/base/web/js/price-bundle.js. Which is the reason why I can't override it or extend it. I am not sure if there is a way to get around this or a different approach I need to take to this issue that I don't know about.



Any help and suggestions are greatly appreciated.







magento2 javascript overrides magento-2.0 requirejs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 6 '16 at 19:23







Noemi Quezada

















asked Jun 2 '16 at 22:09









Noemi QuezadaNoemi Quezada

494729




494729








  • 1





    We may have architecture for this. Checking.

    – benmarks
    Jun 7 '16 at 16:06






  • 2





    Confirmed, we have JavaScript mixins which can do this. You'll get a response soon.

    – benmarks
    Jun 8 '16 at 15:34











  • @benmarks thank you so much for looking into my issue, I had also thought about JavaScript mixins, but the first time I attempted it I was having issues accessing some of the $.mage.priceBundle parameters and methods.

    – Noemi Quezada
    Jun 8 '16 at 21:26











  • @NoemiQuezada Please mark the correct answer

    – Stevie G
    Jan 13 '17 at 15:00











  • Hi @NoemiQuezada have you got solution for it. please share the piece of code if you find any solution regrading it

    – Himanshu
    54 mins ago














  • 1





    We may have architecture for this. Checking.

    – benmarks
    Jun 7 '16 at 16:06






  • 2





    Confirmed, we have JavaScript mixins which can do this. You'll get a response soon.

    – benmarks
    Jun 8 '16 at 15:34











  • @benmarks thank you so much for looking into my issue, I had also thought about JavaScript mixins, but the first time I attempted it I was having issues accessing some of the $.mage.priceBundle parameters and methods.

    – Noemi Quezada
    Jun 8 '16 at 21:26











  • @NoemiQuezada Please mark the correct answer

    – Stevie G
    Jan 13 '17 at 15:00











  • Hi @NoemiQuezada have you got solution for it. please share the piece of code if you find any solution regrading it

    – Himanshu
    54 mins ago








1




1





We may have architecture for this. Checking.

– benmarks
Jun 7 '16 at 16:06





We may have architecture for this. Checking.

– benmarks
Jun 7 '16 at 16:06




2




2





Confirmed, we have JavaScript mixins which can do this. You'll get a response soon.

– benmarks
Jun 8 '16 at 15:34





Confirmed, we have JavaScript mixins which can do this. You'll get a response soon.

– benmarks
Jun 8 '16 at 15:34













@benmarks thank you so much for looking into my issue, I had also thought about JavaScript mixins, but the first time I attempted it I was having issues accessing some of the $.mage.priceBundle parameters and methods.

– Noemi Quezada
Jun 8 '16 at 21:26





@benmarks thank you so much for looking into my issue, I had also thought about JavaScript mixins, but the first time I attempted it I was having issues accessing some of the $.mage.priceBundle parameters and methods.

– Noemi Quezada
Jun 8 '16 at 21:26













@NoemiQuezada Please mark the correct answer

– Stevie G
Jan 13 '17 at 15:00





@NoemiQuezada Please mark the correct answer

– Stevie G
Jan 13 '17 at 15:00













Hi @NoemiQuezada have you got solution for it. please share the piece of code if you find any solution regrading it

– Himanshu
54 mins ago





Hi @NoemiQuezada have you got solution for it. please share the piece of code if you find any solution regrading it

– Himanshu
54 mins ago










4 Answers
4






active

oldest

votes


















1














I had the same issue like you and found a workaround, but don't know if it is helpful. I am going to share it anyway.



I resigned to override the function. Then I was trying to override the whole widget, but couldn't get it to work either. The widget wasn't overridden and the magento standard widget was loaded.



I inspected the generated pub/static/_requirejs/frontend/<Vendor>/<theme>/<location>/requirejs-config.js file. It seems to me, that the modules' requirejs configurations are inserted in a alphabetical order. Thus, the priceBundle variable of my module was overridden by the one of the magento-bundle module, because my vendor starts with a 'C'.



For testing purposes I created a new module and changed the vendor to 'XC...'. After that the overriding of the whole widget works.



But I am still interested in how to override just one function.






share|improve this answer


























  • I tried this adding a Z in front of Endertech for the vendor name and now for the first time my price-bundle.js file gets loaded. Thank you! Like you though, I would like to understand how I can just override one method. However, after testing the solution I realized that another method has to be modified slightly because when you update a product that is in the cart the product summary is not updated correctly.

    – Noemi Quezada
    Jun 9 '16 at 19:47











  • I'm glad that the workaround is working for you, too. Now, I'm wondering about the quantity of the radios when you update a product that is in the cart. It seams to me, that the quantity is being set to the default instead of to the user configured one. I did not changed anything about radios and can reproduce this behavior in other online demo shops. I already opened an issue at github: github.com/magento/magento2/issues/4942. Thus, don't waste your time, if you experience the same issue.

    – Densen
    Jun 15 '16 at 8:48





















2














You should intrude in requrejs sequence be adding dependencies for your extension, config will be:



var config = {

map: {
"*": {
priceBundle: 'SOURCE_TO_EXTENDED_PRICE_BUNDLE'
},
'Endertech_BundleExtended/js/price-bundle': {'priceBundle': 'SOURCE_TO_ORIGINAL_PRICE_BUNDLE'}
}

};





share|improve this answer


























  • I tried this approach, but my file did not load at all.

    – Noemi Quezada
    Jun 9 '16 at 19:44



















1














What I also found that worked was the following



In the module requirejs-config:



var config = {
map: {
'*': {
'mage/SwatchRenderer': 'Magento_Swatches/js/swatch-renderer',
'Magento_Swatches/js/swatch-renderer': 'MyVendor_MyModule/js/swatch-renderer'
}
}
};


And then I created a mymodule/view/frontend/web/js/swatch-renderer.js that contained:



define([
'jquery',
'jquery/ui',
'mage/SwatchRenderer',
], function ($) {
$.widget('myvendor.SwatchRenderer', $.mage.SwatchRenderer, {
_Rewind: function (controls) {
controls.find('div[option-id], option[option-id]').removeClass('disabled').removeAttr('disabled');
controls.find('div[option-empty], option[option-empty]').attr('disabled', true).addClass('disabled');
console.log('test');
},
});

return $.myvendor.SwatchRenderer;
});





share|improve this answer































    0














    If your core js use widget then you also call that widget and return that widget variable in a mixin.



    Bundle mixin you have to create requirejs-config.js in your custom module at
    Vendor/Extension/view/frontend/requirejs-config.js put below code in appropriate js



    requirejs-config.js :



    var config = {
    config: {
    mixins: {
    'Magento_Bundle/js/price-bundle': {
    'Vendor_Extension/js/price-bundle-mixin': true
    }
    }
    },
    };


    price-bundle-mixin :



    define([
    'jquery',
    'underscore',
    'mage/template',
    'priceUtils',
    'priceBox'
    ], function ($, _, mageTemplate, utils) {
    'use strict';

    return function (priceBundle) {

    $.widget('mage.priceBundle', priceBundle, {
    // function which you want to overwrite
    });

    // don't forget to add a function which is used by your
    // functions, else it will show undefined function error

    return $.mage.priceBundle;
    };
    });




    share























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "479"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f118153%2fmagento-2-how-to-override-core-js-module-price-bundle-js%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      I had the same issue like you and found a workaround, but don't know if it is helpful. I am going to share it anyway.



      I resigned to override the function. Then I was trying to override the whole widget, but couldn't get it to work either. The widget wasn't overridden and the magento standard widget was loaded.



      I inspected the generated pub/static/_requirejs/frontend/<Vendor>/<theme>/<location>/requirejs-config.js file. It seems to me, that the modules' requirejs configurations are inserted in a alphabetical order. Thus, the priceBundle variable of my module was overridden by the one of the magento-bundle module, because my vendor starts with a 'C'.



      For testing purposes I created a new module and changed the vendor to 'XC...'. After that the overriding of the whole widget works.



      But I am still interested in how to override just one function.






      share|improve this answer


























      • I tried this adding a Z in front of Endertech for the vendor name and now for the first time my price-bundle.js file gets loaded. Thank you! Like you though, I would like to understand how I can just override one method. However, after testing the solution I realized that another method has to be modified slightly because when you update a product that is in the cart the product summary is not updated correctly.

        – Noemi Quezada
        Jun 9 '16 at 19:47











      • I'm glad that the workaround is working for you, too. Now, I'm wondering about the quantity of the radios when you update a product that is in the cart. It seams to me, that the quantity is being set to the default instead of to the user configured one. I did not changed anything about radios and can reproduce this behavior in other online demo shops. I already opened an issue at github: github.com/magento/magento2/issues/4942. Thus, don't waste your time, if you experience the same issue.

        – Densen
        Jun 15 '16 at 8:48


















      1














      I had the same issue like you and found a workaround, but don't know if it is helpful. I am going to share it anyway.



      I resigned to override the function. Then I was trying to override the whole widget, but couldn't get it to work either. The widget wasn't overridden and the magento standard widget was loaded.



      I inspected the generated pub/static/_requirejs/frontend/<Vendor>/<theme>/<location>/requirejs-config.js file. It seems to me, that the modules' requirejs configurations are inserted in a alphabetical order. Thus, the priceBundle variable of my module was overridden by the one of the magento-bundle module, because my vendor starts with a 'C'.



      For testing purposes I created a new module and changed the vendor to 'XC...'. After that the overriding of the whole widget works.



      But I am still interested in how to override just one function.






      share|improve this answer


























      • I tried this adding a Z in front of Endertech for the vendor name and now for the first time my price-bundle.js file gets loaded. Thank you! Like you though, I would like to understand how I can just override one method. However, after testing the solution I realized that another method has to be modified slightly because when you update a product that is in the cart the product summary is not updated correctly.

        – Noemi Quezada
        Jun 9 '16 at 19:47











      • I'm glad that the workaround is working for you, too. Now, I'm wondering about the quantity of the radios when you update a product that is in the cart. It seams to me, that the quantity is being set to the default instead of to the user configured one. I did not changed anything about radios and can reproduce this behavior in other online demo shops. I already opened an issue at github: github.com/magento/magento2/issues/4942. Thus, don't waste your time, if you experience the same issue.

        – Densen
        Jun 15 '16 at 8:48
















      1












      1








      1







      I had the same issue like you and found a workaround, but don't know if it is helpful. I am going to share it anyway.



      I resigned to override the function. Then I was trying to override the whole widget, but couldn't get it to work either. The widget wasn't overridden and the magento standard widget was loaded.



      I inspected the generated pub/static/_requirejs/frontend/<Vendor>/<theme>/<location>/requirejs-config.js file. It seems to me, that the modules' requirejs configurations are inserted in a alphabetical order. Thus, the priceBundle variable of my module was overridden by the one of the magento-bundle module, because my vendor starts with a 'C'.



      For testing purposes I created a new module and changed the vendor to 'XC...'. After that the overriding of the whole widget works.



      But I am still interested in how to override just one function.






      share|improve this answer















      I had the same issue like you and found a workaround, but don't know if it is helpful. I am going to share it anyway.



      I resigned to override the function. Then I was trying to override the whole widget, but couldn't get it to work either. The widget wasn't overridden and the magento standard widget was loaded.



      I inspected the generated pub/static/_requirejs/frontend/<Vendor>/<theme>/<location>/requirejs-config.js file. It seems to me, that the modules' requirejs configurations are inserted in a alphabetical order. Thus, the priceBundle variable of my module was overridden by the one of the magento-bundle module, because my vendor starts with a 'C'.



      For testing purposes I created a new module and changed the vendor to 'XC...'. After that the overriding of the whole widget works.



      But I am still interested in how to override just one function.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Jun 9 '16 at 9:36

























      answered Jun 9 '16 at 9:17









      DensenDensen

      565




      565













      • I tried this adding a Z in front of Endertech for the vendor name and now for the first time my price-bundle.js file gets loaded. Thank you! Like you though, I would like to understand how I can just override one method. However, after testing the solution I realized that another method has to be modified slightly because when you update a product that is in the cart the product summary is not updated correctly.

        – Noemi Quezada
        Jun 9 '16 at 19:47











      • I'm glad that the workaround is working for you, too. Now, I'm wondering about the quantity of the radios when you update a product that is in the cart. It seams to me, that the quantity is being set to the default instead of to the user configured one. I did not changed anything about radios and can reproduce this behavior in other online demo shops. I already opened an issue at github: github.com/magento/magento2/issues/4942. Thus, don't waste your time, if you experience the same issue.

        – Densen
        Jun 15 '16 at 8:48





















      • I tried this adding a Z in front of Endertech for the vendor name and now for the first time my price-bundle.js file gets loaded. Thank you! Like you though, I would like to understand how I can just override one method. However, after testing the solution I realized that another method has to be modified slightly because when you update a product that is in the cart the product summary is not updated correctly.

        – Noemi Quezada
        Jun 9 '16 at 19:47











      • I'm glad that the workaround is working for you, too. Now, I'm wondering about the quantity of the radios when you update a product that is in the cart. It seams to me, that the quantity is being set to the default instead of to the user configured one. I did not changed anything about radios and can reproduce this behavior in other online demo shops. I already opened an issue at github: github.com/magento/magento2/issues/4942. Thus, don't waste your time, if you experience the same issue.

        – Densen
        Jun 15 '16 at 8:48



















      I tried this adding a Z in front of Endertech for the vendor name and now for the first time my price-bundle.js file gets loaded. Thank you! Like you though, I would like to understand how I can just override one method. However, after testing the solution I realized that another method has to be modified slightly because when you update a product that is in the cart the product summary is not updated correctly.

      – Noemi Quezada
      Jun 9 '16 at 19:47





      I tried this adding a Z in front of Endertech for the vendor name and now for the first time my price-bundle.js file gets loaded. Thank you! Like you though, I would like to understand how I can just override one method. However, after testing the solution I realized that another method has to be modified slightly because when you update a product that is in the cart the product summary is not updated correctly.

      – Noemi Quezada
      Jun 9 '16 at 19:47













      I'm glad that the workaround is working for you, too. Now, I'm wondering about the quantity of the radios when you update a product that is in the cart. It seams to me, that the quantity is being set to the default instead of to the user configured one. I did not changed anything about radios and can reproduce this behavior in other online demo shops. I already opened an issue at github: github.com/magento/magento2/issues/4942. Thus, don't waste your time, if you experience the same issue.

      – Densen
      Jun 15 '16 at 8:48







      I'm glad that the workaround is working for you, too. Now, I'm wondering about the quantity of the radios when you update a product that is in the cart. It seams to me, that the quantity is being set to the default instead of to the user configured one. I did not changed anything about radios and can reproduce this behavior in other online demo shops. I already opened an issue at github: github.com/magento/magento2/issues/4942. Thus, don't waste your time, if you experience the same issue.

      – Densen
      Jun 15 '16 at 8:48















      2














      You should intrude in requrejs sequence be adding dependencies for your extension, config will be:



      var config = {

      map: {
      "*": {
      priceBundle: 'SOURCE_TO_EXTENDED_PRICE_BUNDLE'
      },
      'Endertech_BundleExtended/js/price-bundle': {'priceBundle': 'SOURCE_TO_ORIGINAL_PRICE_BUNDLE'}
      }

      };





      share|improve this answer


























      • I tried this approach, but my file did not load at all.

        – Noemi Quezada
        Jun 9 '16 at 19:44
















      2














      You should intrude in requrejs sequence be adding dependencies for your extension, config will be:



      var config = {

      map: {
      "*": {
      priceBundle: 'SOURCE_TO_EXTENDED_PRICE_BUNDLE'
      },
      'Endertech_BundleExtended/js/price-bundle': {'priceBundle': 'SOURCE_TO_ORIGINAL_PRICE_BUNDLE'}
      }

      };





      share|improve this answer


























      • I tried this approach, but my file did not load at all.

        – Noemi Quezada
        Jun 9 '16 at 19:44














      2












      2








      2







      You should intrude in requrejs sequence be adding dependencies for your extension, config will be:



      var config = {

      map: {
      "*": {
      priceBundle: 'SOURCE_TO_EXTENDED_PRICE_BUNDLE'
      },
      'Endertech_BundleExtended/js/price-bundle': {'priceBundle': 'SOURCE_TO_ORIGINAL_PRICE_BUNDLE'}
      }

      };





      share|improve this answer















      You should intrude in requrejs sequence be adding dependencies for your extension, config will be:



      var config = {

      map: {
      "*": {
      priceBundle: 'SOURCE_TO_EXTENDED_PRICE_BUNDLE'
      },
      'Endertech_BundleExtended/js/price-bundle': {'priceBundle': 'SOURCE_TO_ORIGINAL_PRICE_BUNDLE'}
      }

      };






      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Jun 9 '16 at 11:42

























      answered Jun 9 '16 at 11:38









      imelnychenkoimelnychenko

      212




      212













      • I tried this approach, but my file did not load at all.

        – Noemi Quezada
        Jun 9 '16 at 19:44



















      • I tried this approach, but my file did not load at all.

        – Noemi Quezada
        Jun 9 '16 at 19:44

















      I tried this approach, but my file did not load at all.

      – Noemi Quezada
      Jun 9 '16 at 19:44





      I tried this approach, but my file did not load at all.

      – Noemi Quezada
      Jun 9 '16 at 19:44











      1














      What I also found that worked was the following



      In the module requirejs-config:



      var config = {
      map: {
      '*': {
      'mage/SwatchRenderer': 'Magento_Swatches/js/swatch-renderer',
      'Magento_Swatches/js/swatch-renderer': 'MyVendor_MyModule/js/swatch-renderer'
      }
      }
      };


      And then I created a mymodule/view/frontend/web/js/swatch-renderer.js that contained:



      define([
      'jquery',
      'jquery/ui',
      'mage/SwatchRenderer',
      ], function ($) {
      $.widget('myvendor.SwatchRenderer', $.mage.SwatchRenderer, {
      _Rewind: function (controls) {
      controls.find('div[option-id], option[option-id]').removeClass('disabled').removeAttr('disabled');
      controls.find('div[option-empty], option[option-empty]').attr('disabled', true).addClass('disabled');
      console.log('test');
      },
      });

      return $.myvendor.SwatchRenderer;
      });





      share|improve this answer




























        1














        What I also found that worked was the following



        In the module requirejs-config:



        var config = {
        map: {
        '*': {
        'mage/SwatchRenderer': 'Magento_Swatches/js/swatch-renderer',
        'Magento_Swatches/js/swatch-renderer': 'MyVendor_MyModule/js/swatch-renderer'
        }
        }
        };


        And then I created a mymodule/view/frontend/web/js/swatch-renderer.js that contained:



        define([
        'jquery',
        'jquery/ui',
        'mage/SwatchRenderer',
        ], function ($) {
        $.widget('myvendor.SwatchRenderer', $.mage.SwatchRenderer, {
        _Rewind: function (controls) {
        controls.find('div[option-id], option[option-id]').removeClass('disabled').removeAttr('disabled');
        controls.find('div[option-empty], option[option-empty]').attr('disabled', true).addClass('disabled');
        console.log('test');
        },
        });

        return $.myvendor.SwatchRenderer;
        });





        share|improve this answer


























          1












          1








          1







          What I also found that worked was the following



          In the module requirejs-config:



          var config = {
          map: {
          '*': {
          'mage/SwatchRenderer': 'Magento_Swatches/js/swatch-renderer',
          'Magento_Swatches/js/swatch-renderer': 'MyVendor_MyModule/js/swatch-renderer'
          }
          }
          };


          And then I created a mymodule/view/frontend/web/js/swatch-renderer.js that contained:



          define([
          'jquery',
          'jquery/ui',
          'mage/SwatchRenderer',
          ], function ($) {
          $.widget('myvendor.SwatchRenderer', $.mage.SwatchRenderer, {
          _Rewind: function (controls) {
          controls.find('div[option-id], option[option-id]').removeClass('disabled').removeAttr('disabled');
          controls.find('div[option-empty], option[option-empty]').attr('disabled', true).addClass('disabled');
          console.log('test');
          },
          });

          return $.myvendor.SwatchRenderer;
          });





          share|improve this answer













          What I also found that worked was the following



          In the module requirejs-config:



          var config = {
          map: {
          '*': {
          'mage/SwatchRenderer': 'Magento_Swatches/js/swatch-renderer',
          'Magento_Swatches/js/swatch-renderer': 'MyVendor_MyModule/js/swatch-renderer'
          }
          }
          };


          And then I created a mymodule/view/frontend/web/js/swatch-renderer.js that contained:



          define([
          'jquery',
          'jquery/ui',
          'mage/SwatchRenderer',
          ], function ($) {
          $.widget('myvendor.SwatchRenderer', $.mage.SwatchRenderer, {
          _Rewind: function (controls) {
          controls.find('div[option-id], option[option-id]').removeClass('disabled').removeAttr('disabled');
          controls.find('div[option-empty], option[option-empty]').attr('disabled', true).addClass('disabled');
          console.log('test');
          },
          });

          return $.myvendor.SwatchRenderer;
          });






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Sep 12 '16 at 13:05









          KoenKoen

          111




          111























              0














              If your core js use widget then you also call that widget and return that widget variable in a mixin.



              Bundle mixin you have to create requirejs-config.js in your custom module at
              Vendor/Extension/view/frontend/requirejs-config.js put below code in appropriate js



              requirejs-config.js :



              var config = {
              config: {
              mixins: {
              'Magento_Bundle/js/price-bundle': {
              'Vendor_Extension/js/price-bundle-mixin': true
              }
              }
              },
              };


              price-bundle-mixin :



              define([
              'jquery',
              'underscore',
              'mage/template',
              'priceUtils',
              'priceBox'
              ], function ($, _, mageTemplate, utils) {
              'use strict';

              return function (priceBundle) {

              $.widget('mage.priceBundle', priceBundle, {
              // function which you want to overwrite
              });

              // don't forget to add a function which is used by your
              // functions, else it will show undefined function error

              return $.mage.priceBundle;
              };
              });




              share




























                0














                If your core js use widget then you also call that widget and return that widget variable in a mixin.



                Bundle mixin you have to create requirejs-config.js in your custom module at
                Vendor/Extension/view/frontend/requirejs-config.js put below code in appropriate js



                requirejs-config.js :



                var config = {
                config: {
                mixins: {
                'Magento_Bundle/js/price-bundle': {
                'Vendor_Extension/js/price-bundle-mixin': true
                }
                }
                },
                };


                price-bundle-mixin :



                define([
                'jquery',
                'underscore',
                'mage/template',
                'priceUtils',
                'priceBox'
                ], function ($, _, mageTemplate, utils) {
                'use strict';

                return function (priceBundle) {

                $.widget('mage.priceBundle', priceBundle, {
                // function which you want to overwrite
                });

                // don't forget to add a function which is used by your
                // functions, else it will show undefined function error

                return $.mage.priceBundle;
                };
                });




                share


























                  0












                  0








                  0







                  If your core js use widget then you also call that widget and return that widget variable in a mixin.



                  Bundle mixin you have to create requirejs-config.js in your custom module at
                  Vendor/Extension/view/frontend/requirejs-config.js put below code in appropriate js



                  requirejs-config.js :



                  var config = {
                  config: {
                  mixins: {
                  'Magento_Bundle/js/price-bundle': {
                  'Vendor_Extension/js/price-bundle-mixin': true
                  }
                  }
                  },
                  };


                  price-bundle-mixin :



                  define([
                  'jquery',
                  'underscore',
                  'mage/template',
                  'priceUtils',
                  'priceBox'
                  ], function ($, _, mageTemplate, utils) {
                  'use strict';

                  return function (priceBundle) {

                  $.widget('mage.priceBundle', priceBundle, {
                  // function which you want to overwrite
                  });

                  // don't forget to add a function which is used by your
                  // functions, else it will show undefined function error

                  return $.mage.priceBundle;
                  };
                  });




                  share













                  If your core js use widget then you also call that widget and return that widget variable in a mixin.



                  Bundle mixin you have to create requirejs-config.js in your custom module at
                  Vendor/Extension/view/frontend/requirejs-config.js put below code in appropriate js



                  requirejs-config.js :



                  var config = {
                  config: {
                  mixins: {
                  'Magento_Bundle/js/price-bundle': {
                  'Vendor_Extension/js/price-bundle-mixin': true
                  }
                  }
                  },
                  };


                  price-bundle-mixin :



                  define([
                  'jquery',
                  'underscore',
                  'mage/template',
                  'priceUtils',
                  'priceBox'
                  ], function ($, _, mageTemplate, utils) {
                  'use strict';

                  return function (priceBundle) {

                  $.widget('mage.priceBundle', priceBundle, {
                  // function which you want to overwrite
                  });

                  // don't forget to add a function which is used by your
                  // functions, else it will show undefined function error

                  return $.mage.priceBundle;
                  };
                  });





                  share











                  share


                  share










                  answered 4 mins ago









                  HimanshuHimanshu

                  965622




                  965622






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Magento Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f118153%2fmagento-2-how-to-override-core-js-module-price-bundle-js%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      “%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

                      How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

                      夢乃愛華...