46
votes
Accepted
How to rewrite widget function with mixins Magento 2.1.1
requirejs-config.js
var config = {
config: {
mixins: {
'Magento_Swatches/js/swatch-renderer': {
'path/to/your/mixin': true
}
}
}
};
...
18
votes
Accepted
How Are the Things Magento 2 calls "mixins" Implemented?
I'd like to go straight to your questions and then I'll try to make it clear on what you can actually do with the mixins plugin. So, first things first.
Implementation
The main thing here is the ...
13
votes
Accepted
What is mixin in Magento 2?
A mixin is a class whose methods are added to, or mixed in, with another class.
A base class includes the methods from a mixin instead of inheriting from it. This allows you to add to or augment the ...
8
votes
How to load shipping methods on country and postcode change?
You have to add mixin for shipping-rates-validation-rules
Add mixins in requirejs-config.js
app/code/Vendor/ShippingModule/view/frontend/requirejs-config.js
var config = {
config: {
...
8
votes
Accepted
Magento 2 javascript plugin after method is executed in wrong time
If you look at target file Magento/Checkout/view/frontend/web/js/view/shipping.js,you'll see that this is requirejs module which returns UiComponent (child of Magento_Ui/js/form/form).
In your ...
7
votes
Accepted
Magento 2 - Override Mixin with another Mixin
You can disable original mixin and enable yours by putting this snippet in your module's requirejs config:
var config = {
config: {
mixins: {
'mage/validation': {
...
5
votes
Magento 2 javascript plugin after method is executed in wrong time
I'm not 100% sure, but I think mixins on ui components do not work as you are expecting it, since ui components return an ui component object which work slightly differtent, like further described ...
5
votes
Accepted
When to use mixin js in magento2?
In your case, you don't need to use mixin js or override js. You can find in the method-group.js:
vendor/magento/module-checkout/view/frontend/web/js/model/payment/method-group.js
Title is a ...
4
votes
How to extend admin js in magento 2 by mixins
I am curious to know why would Magento won't allow using mixins on such file... any quick explanation about it?
4
votes
Accepted
How to override price-utils.js specific method?
Using mixins is to follow the best practice. But in your script, should try:
define([
'jquery',
'underscore'
],
function ($, _) {
'use strict';
return function (target) ...
4
votes
How Are the Things Magento 2 calls "mixins" Implemented?
To round out Denis Rul's answer.
So, if you look at a Magento page, here are the three <script/> tags that load Magento.
<script type="text/javascript" src="http://magento.example.com/...
3
votes
Accepted
.lib-url-check is undefined Magento 2.3 static content deploy error
The lib-url-check mixin has been removed by the look of it, therefore you need to update your LESS files.
See this link for the commits - https://github.com/magento/magento2/search?p=1&q=lib-url-...
3
votes
Magento 2 combine two functionality s using a single mixin js file?
A mixin is a class whose methods are added to, or mixed in, with another class.
A base class includes the methods from a mixin instead of inheriting from it. This allows you to add to or augment the ...
3
votes
How to rewrite widget function with mixins Magento 2.1.1
Edit: my answer is not using mixins. To my knowledge, mixins only work for methods rewrites and properties. In your case, it's pure JS being called directly outside of a method.
You can do it via a ...
3
votes
When to use mixins and when to use map?
The choice of which of those techniques to use is often relative and can be decided by general principles. There are a few exceptions when a mixin would not accomplish the goal and therefore, map must ...
3
votes
Accepted
Can't get Magento2's .media-width() LESS mixin to work
Ok, so I discovered a little more about this but as @circlesix pointed out it's not possible to use these LESS mixins nested like this.
Furthermore if you look at the <head> section of Magento ...
3
votes
Magento 2 - Override Mixin with another Mixin
I was able to solve it thanks to @Michał Biarda.
There was a bug in the extension Dotdigitalgroup_Sms, they forgot to return $.mage.validation.
So I have overriden it by mapping and fixed it.
But ...
3
votes
Accepted
Magento 2 Bundle Product Page - Remove Slide Down
To disable the slide down when clicking the Customize and Add to Cart button on the bundle product page, create a new JS mixin to override the default slideDown option in mage.slide JS widget to set ...
2
votes
How to override Magento 2 js using Mixins?
These some ways to overwrite core Magento 2 JS using mixin
With js file returned $.mage.[widgetName]
Your target file must be using $.widget:
ex: source file: Magento_Checkout/js/shopping-cart
...
2
votes
Accepted
Access Variables passed to a function modified/wrapped with a mixin
The arguments variable seemed to contain what i needed. After logging the object the specific element i needed seemed to be stored in: arguments[1][0]
Final code:
define([
'jquery',
'mage/...
2
votes
Accepted
How to extend admin js in magento 2 by mixins
You may not use js mixin for the particular js file you try to override (i.e /vendor/magento/module-sales/view/adminhtml/web/order/create/scripts.js). Also, your require-config.js declaration is ...
2
votes
Magento 2 : Creating JS Mixins for anonymous functions?
I will assume you use extra module for purpose customises on place order js
In module you need define file requirejs-config.js
path
app\code\YourVendor\ModuleName\view\frontend\requirejs-config.js
...
2
votes
mixin is not a function
You probably need to check and change the location of your mixin.
Refer to the documentation
Update: Remove single quotes in your mixins declaration:
reference
var config = {
config: {
...
2
votes
How to extend admin js in magento 2 by mixins
Actually, there is another way to extend a class method that worked for me. Example:
scripts-mixins.js
define([], function () {
'use strict';
if (typeof AdminOrder !== "undefined") {...
2
votes
Accepted
css and js not found in magento 2.3.5
Step -1
Go To Magento\Framework\View\Element\Template\File\Validator.php
replace isPathInDirectories() Method
protected function isPathInDirectories($path, $directories)
{
$realPath = ...
2
votes
Accepted
how to create a mixin js in magento
Two catches here with this type of mixin (there are a couple of ways to use mixins):
The original Magento_Customer/js/model/customer/address returns a javascript function
The object you are trying to ...
1
vote
Magento 2 - advanced JS bundling mixins
I ran into the same problem. There is a patch to solve it. You can find out more here:
https://github.com/magento/magento2/pull/25587
Download the mixins.js file from here:
https://raw....
1
vote
Magento 2 combine two functionality s using a single mixin js file?
I have tried this way and its working fine now
requirejs-config.js
var config = {
config: {
mixins: {
'Magento_Swatches/js/swatch-renderer': {
'...
1
vote
Accepted
Magento 2 pass php session variable to minicart & hide proceed to checkout
If you want to pass your PHP SESSION variable data in your JS then please follow below steps :
Create di.xml file here in your custom module
app/code/Vendor/Module/etc/di.xml
Content for this ...
1
vote
Magento2 Mixins: How to write a requirejs-config.js?
What exactly do I need to add to the requirejs-config.js for adding a mixin?
In theme - app/design/frontend/Vendor/theme/requirejs-config.js
In module - app/code/Vendor/Module/view/frontend/requirejs-...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
mixins × 67magento2 × 50
javascript × 21
requirejs × 16
checkout × 10
overrides × 5
knockoutjs × 4
requirejs-config.js × 4
magento2.3 × 3
magento2.2 × 3
widget × 3
less × 3
magento-2.1 × 2
jquery × 2
plugin × 2
magento2.2.6 × 2
mini-cart × 2
static-content × 2
static-content-deploy × 2
module × 1
cart × 1
configurable-product × 1
error × 1
adminhtml × 1
theme × 1