Questions tagged [knockoutjs]

Denotes questions related to Knockout use in Magento2

Filter by
Sorted by
Tagged with
2
votes
1answer
2k views

Magento 2 UI grid non db dataprovider and pagination issue

I'm trying to us the UI grid component to create a grid in the backend that displays information that's not from the database. So far I created the XML files, the controller and a custom data provider....
0
votes
0answers
9 views

How to unselect shipping address on checkout

I would like to know, how can I unselect default shipping address that load when I go to the first step on checkout. My problem is when I'm trying to add new address, I need to unselect any address ...
2
votes
1answer
953 views

Knockout js child components

I am making a custom module before adding a product on cart with 3 options : The upload option should display an upload form like : My initial idea was to make two knockout components : ...
1
vote
2answers
1k views

Magento 2.1.2 : how to trigger UI Component onUpdate() on load

I currently have a UI Component (which extends the default select-component), and I want to do something when the select changes it's value. So I use the onUpdate()-method to hook into this: define([ ...
7
votes
4answers
13k views

What Programmatically Triggers Magento 2's Shipping Rates to Update

When you're filling out the Shipping Address form in Magento 2, periodically Magento will make an ajax request for the URL http://magento.example.com/rest/default/V1/guest-carts/[hash]/estimate-...
0
votes
1answer
1k views

Magento2 : While bind Custom knockout js to html it return only default value

/app/design/frontend/Vendor/custom_theme/Magento_CheckoutAgreements/templates/additional_agreements.phtml I have this code inside .phtml: <div data-bind="scope: 'checkout-agreements-component-...
0
votes
1answer
17 views

Magento 2 - knockoutjs template ignores script tag

I try to add a script tag with a console.log("hello world"); message in the knockoutjs template vendor/magento/module-checkout/view/frontend/web/template/cart/shipping-rates.html This is the ...
1
vote
1answer
92 views

<referenceBlock name=“header.container” remove=“true” /> removes minicart functionality

I've added <referenceBlock name="header.container" remove="true" /> to my themes default.xml and instead has been replaced with: <referenceContainer name="page....
0
votes
1answer
20 views

Do you know any good courses/tutorials/blogs?

I am learning more and more about Magento 2 yet I still feel like there is much to learn. I was wondering what good sources/methods of learning the following subjects are. Basics Things like the ...
2
votes
1answer
984 views

Payment method with custom form in Knockout js

I've created a custom payment method successfully in Magento2. When this custom payment method selected, I need a form to display a text field and submit button that will hit some AJAX Api's using in ...
0
votes
1answer
31 views

Knockout observable is not accessible inside function

So I am working with Knockout inside Magento 2.3.4, and I am setting a custom observable value on initialize, and then I am trying to access that observable and change the value inside a function. ...
1
vote
1answer
31 views

Cart summary_count not updated when “add to cart” is pressed

I'm using the following code to show the total number of items in a users cart: <span data-bind="text: JSON.parse(window.localStorage.getItem('mage-cache-storage')).cart.summary_count">...
1
vote
2answers
625 views

Why data bind template is not working on 2.2 or greater?

I was studying about Knockout.js and how it works with Magento 2. Then I reached the topic: template integration, in the first sample of it I'm presented to this notation: <div data-bind="...
0
votes
1answer
796 views

Magento 2 :What is the different between invalidate and reload if they both update the sections?

If some section should be updated then customerData.invalidate(sections) if you sure, that you really need update some section you can always do something like this: customerData.reload(['cart'], ...
0
votes
1answer
814 views

Magento 2 - Using jQuery on HTML page

I have a custom offline payment module and I am trying to use jQuery to hide a div in frontend/web/template/payment.html: <script> require([ 'jquery' ], function($){ if ( $('#payroll-form'...
0
votes
2answers
55 views

How To Pass data from Helper Data to Knockout JS file Magento 2

How i can pass helper data to Knockout JS to show it on my html file. Actually i am working on minicart and i want to show the product Qty as Dropdown and get value from Helperdata. Any help would be ...
5
votes
2answers
2k views

Uncaught TypeError: Cannot read property 'apply' of undefined at Function.ko.observableArray.fn.(anonymous function) [as push]

I have created a custom attribute(multiselect) for product with the same filter type as category selection on Magento 2. Attribute selection is working fine when creating a new product however it is ...
0
votes
1answer
761 views

Magento 2 - Add a message to a ko template that is created through a LayoutProcessorPlugin

I need to add message "Need it by today? Anything is possible, it's just a phone call away" in a KO template. However, this template is created through the afterProcess method LayoutProcessPlugin.php ...
0
votes
0answers
13 views

How to hide special price based on a checkbox?

Some people want the ability to hide special price and only show retail price. I want to do this in knockout by adding a class to the parent container. This class will be set based on a cookie that is ...
0
votes
0answers
18 views

How to reload a component on checkout page when shipping address is modified

I am using Amasty Deliverydate module, this module allows customer to select delivery date and time on checkout step. I am trying to customize this module and we have developed a feature where admin ...
5
votes
1answer
2k views

Why shipping methods not updated on changing of checkout fields?

In the past when I fill one of the checkout fields then shipping method section under the checkout page refreshed and then updated like this: But now shipping method not updated by calling ajax (or ...
3
votes
0answers
29 views

Magento2 Holepunch Cache for Pricing

I have a Magento 2 website which has been set up to allow customers to have their own pricing. However, as a result of this the FPC (for category and product pages) is now being generated uniquely for ...
3
votes
1answer
785 views

Custom Checkout Step Fields not in Post Data

I have created a new checkout step with 4 form fields. The step is called additional-order-info. I created the step and the form with the help of the devdocs for Magento 2(.1). I have also created ...
0
votes
0answers
23 views

How to display cart item count in custom header using JavaScript?

I've created a custom header that works fine. I replaced Magento's cart, and instead added a shopping basket icon in the header. Like so: When pressed it redirects to the cart. What I want to do is ...
1
vote
1answer
877 views

Magento2 - Wait for checkout page completely loaded and fire JS code

The goal is to add a piece of JS to manipulate a datepicker on the checkout page. I use a OSC (OneStepCheckout from mageplaza). So far I've followed this documentation and added this mixin: var ...
0
votes
0answers
8 views

Magento2.4 use knockout to identify if user is logged in

I am trying to edit the links in the header.phtml file so that it will show and additional link only if logged in. My issue is it does not seem to work here is my code. The sign up is showing even ...
0
votes
1answer
34 views

Magento 2 Knockout bind on ajax response

I am going crazy with knockout on Magento 2, I am new to knockout and I cannot understand what I am doing wrong. I know there are some related questions posted there but each one is different from ...
3
votes
2answers
59 views

Magento 2 - How does getShippingMethodTitle know the method title in module-tax/view/frontend/web/js/view/checkout/cart/totals/shipping.js

I try to understand knockoutjs and requirejs more but I fail to understand the following case. In checkout the shipping method title is showing in the summary This is the template: vendor/magento/...
4
votes
2answers
2k views

add custom js to the certain input element on the checkout page

My final goal adds custom js to the certain input element on the checkout page what i tried To get element with uiRegistry and on redner add needed code, but failed, i can work with tjis element ...
0
votes
1answer
18 views

Magento 2 - Pass data to checkout during runtime

I created a new carrier method for express shipping. I need to show a dynamic message which I am generating based on the products in the cart. There are some product categories which are not allowed ...
1
vote
1answer
829 views

Magento 2: Shipping method radio button is disabled

In checkout page of Magento 2, all enabled shipping method radio buttons are showing as disabled. Anybody have faced such an issue? I used latest version: 2.1.3
1
vote
1answer
933 views

Magento 2 : how to clear selected Value form Custom UI Component select(Dropdown)

Custom ui component select(Dropdown) <select class="admin__control-select" data-bind=" event:{ change: selectOptionCategory(uid)}, attr: { name: inputName, id: ...
2
votes
3answers
4k views

override knockout html template file in theme

I need to add a class to the cart summary table caption. I want to hide the caption by addding the class sr-only (bootstrap): <caption class="table-caption sr-only" data-bind="text: $t('Total')"&...
1
vote
1answer
814 views

Magento 2 Minicart content not displaying

I'm working on developing my own theme by extending the Magento Blank theme. I'm trying to add the minicart to my header.phtml file. I'm loading the minicart in my header like so: <?php echo $...
0
votes
1answer
46 views

Magento 2 - how to add methods to a javascript file by using mixins?

I am using the extension amasty/single-step-checkout. They are using this mixin... vendor\amasty\module-single-step-checkout\view\frontend\web\js\view\shipping-mixin.js (A) ...to extend this magento ...
10
votes
4answers
5k views

Hide messages after certain interval

How to hide notification messages like success message after adding product to cart or any error messages or notices after few seconds after they appear on the the frontend using knockout js. Example ...
2
votes
1answer
2k views

Magento 2 UiRegistry can't get component element

this my checkout_index_index.xml <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/...
0
votes
2answers
32 views

Magento 2: Translate knockout template html text with variables

Currently i have a knockout template for minicart like this: <!-- ko if: getCartParam('summary_count') --> <div class="items-total"> <!-- ko if: getCartParam('...
1
vote
1answer
3k views

Magento 2 knockout Select options not returning the value

I have Created custom component with select drop down when I select an option and alert the select option it spits out : function observable() { if (arguments.length > 0) { ...
1
vote
1answer
39 views

Magento 2 - How to override frontend javascript file

I need to overwrite a javascript file from a custom module at: vendor\amasty\module-single-step-checkout\view\frontend\web\js\model\one-step-layout.js because I need to replace a code line in it to ...
0
votes
0answers
11 views

Magento 2.3.4 Region Missing When Creating a New Address During Checkout

Running into an issue during checkout on the Shipping step. When you add a new address to ship to during this step, it asks you for your City, State, Zip... however after adding your address, the ...
1
vote
2answers
1k views

magento 2 How to get dropdown selected value in knockout js on button click

I have my custom payment method on the checkout page with the dropdown list. and I want to get that dropdown selected value in knockout js and forward it to controller and store dropdown value in my ...
0
votes
1answer
2k views

magento 2 payment method does not show up in checkout page frontend

I'm trying to implement a new payment method with Magento 2 , so i have implemented the below code to display the payment method as an option within payment methods list , however the issue is "...
0
votes
1answer
69 views

Magento 2 - override knockoutjs template located in base folder

I need to change the value of the maxinput field in the knockoutjs template vendor\magento\module-ui\view\base\web\templates\form\element\input.html so I have to replace the template with my own ...
0
votes
0answers
11 views

Magento 2 Uncaught TypeError: Cannot read property 'confirmation' of undefined in datapost.js

I get this error while using a<> tag with attribute data-post. I used a data-post to re-order. history.phtml <a data-post="value: postData" href="#">Reorder</a> ...
0
votes
0answers
26 views

Uncaught TypeError: Unable to process binding “html: function(){return getInstructions() }” ( Magento 2 )

I'm using a third party one page checkout module on this system. And added an observer "payment_method_is_active" event for the cash on delivery and bank transfer methods to enable them only ...
2
votes
3answers
6k views

Add a CSS class with Knockout JS

In Magento 2, I'm working on this Knockout JS template: app/code/Magento/Checkout/view/frontend/web/template/shipping-address/shipping-method-item.html <!-- /** * Copyright © 2013-2017 Magento, ...
0
votes
1answer
2k views

Magento 2 knockout component scope

I have two knockout components. The xml in layout is: <body> <referenceContainer name="content"> <block class="Vendor\Module\Block\List" name="some_name" template="list....
0
votes
1answer
23 views

Magento 2: Adding a color picker as an attribute to a product form

Please tell me how you can add a color picker as an attribute to the product form. I tried several options from the Internet, well, they did not work.
0
votes
1answer
1k views

magento 2 how to override select-shipping-method.js

when trying to override select-shipping-method.js in my custom module then getting this errors 1 - Uncaught Error: Script error for: Xyz_Customcheckout/js/model/quote http://requirejs.org/docs/...

1
2 3 4 5
15