Questions tagged [knockout]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
24 views

Magento 2: How to check inarray ids in minicart.js

getCartItems: function () { var items = this.getCartParam('items') || []; _.each(items, function (item, key) { console.log(item.product_id); ...
1
vote
1answer
22 views

Magento 2: I want to get product id from getCartItems function in minicart.js

Here is the function in minicart.js getCartItems: function () { var items = this.getCartParam('items') || []; console.log(items); // want to get product id from ...
0
votes
0answers
13 views

Magento 2: Where can I edit the Minicart product image template (KnockoutJS template)?

I'm trying to edit the minicart product image template. I found the parent file: /app/design/frontend/Smartwave/porto/Magento_Checkout/web/template/minicart/item/default.html However it uses a ...
0
votes
0answers
23 views

Magento 2 - Check in mini cart if product is virtual

How can we check in the mini cart if the product is virtual using knockout? Inside the cart and checkout we can use the following, but that is not working in the mini cart. Any idea? <!-- ko if: (...
0
votes
0answers
13 views

Magento 2 reutilize components and template.html

I have been searching how can I use ko component inside another ko component and extend in order to create complex forms. I just don't get it how it works. Whit this I was successfully tu extend a ...
0
votes
2answers
30 views

Show Widget in the Html

I have an html file for checkout where I want to show the widget which is coming from the database . Instead of displaying the widget it shows widget code. I have attached screenshot of the same. ...
0
votes
1answer
19 views

Add foreach loop in knockout

I am using the following condition and its print one value, if(self.options.nearestlocationsBlock) { var firstStore = _.first(locations.items); var newContent = '<div class="store&...
0
votes
1answer
60 views

Magento 2 - How to add custom attribute in knockout “data-bind=”html: 'Product Attribute : ' + product_sku "

I want to show my custom attribute on the wishlist sidebar section, how to add my custom attribute "brand & Size" attributes into this, eg: <div data-bind="html:product_brand &...
1
vote
1answer
1k views

After updating to Magento 2.3.2 checkout page throws error

After I update Magento version from 2.3.0 to 2.3.2 on checkout page I got knockout errors on my console and payments, product items do not show on-page. Before update, it works well. Uncaught ...
0
votes
1answer
46 views

Magento 2: Translate knockout html where “mailto:info@sitename.com” is used

In Magento_Checkout/web/template/minicart/content.html there is a "mailto:info@website.com" used. Now I can translate the last piece by -- ko text: $t('info@website.com') --> <-- /ko --...
5
votes
1answer
1k views

Pass data to child template in cart-items of checkout page

My site is a market place site where vendors(sellers can sell their product). Now i want to customize the to group items in cart by each vendor like this: http://prntscr.com/hmsam6 ...
0
votes
0answers
47 views

datetimepicker is not a function?

After installing the module https://github.com/ecomteck/module-delivery-date on magento2, the input field is displayed without date selection. The console shows an error: knockout.js: 3381 Uncaught ...
0
votes
0answers
27 views

magento2: View model knockout

I am new in magento module development. I was searching for something similar to this https://www.mageplaza.com/devdocs/how-add-custom-discount-magento-2.html I just editied the code in step 2 to meet ...
0
votes
1answer
1k views

Magento 2 - Load knockout content in modal popup

I want to load knockout content in modal popup on the cart page. And to be able to bind button/click events.
0
votes
1answer
949 views

Get config value in html using knockoutjs

I am trying to get config value to html file. My aim is to check if the config value is enabled of it is show a button and if it’s continue normally with out button the button. I am not sure how to ...
0
votes
0answers
42 views

Magento2 Checkout - Add secondary email input in the login form

I have Amasty_Onestepcheckout module installed on a site running on Magento 2.4.1. I have to add a secondary email address that have to be validated as email and equal to the primary email input field....
0
votes
0answers
35 views

Magento 2.3.2 - Very weird checkout cache issue

Hoping someone can help here. We have a Magento 2.3.2 website. There's nothing particularly special, functionality wise about it. It uses cloudflare, which could be a cause, but the hosts assure us ...
0
votes
0answers
19 views

Magento 2 uiComponent multiple instance

I have a view with two templates that use the same uiComponent with Knockout Js. I spent hours trying to discover how to do not share the observables between two different templates. example: <div ...
0
votes
0answers
17 views

Magento2 - Checkout page store credit auto selected

I want to make store credit option auto selected on checkout page. If I click on the "Use Store Credit" button using jQuery, it works perfectly. But I am not able to make it work. To achieve ...
0
votes
1answer
2k views

Magento2 : How to display custom values in checkout page

I am working on checkout page, I have pass some array values to checkout config provider. How to get those values in knockout JS and display by knockout html. Want to display all applied codes in ...
1
vote
2answers
5k views

Magento 2 : knockout data-bind:click not working

I added phtml file using ajax response. There are two buttons available in that phtml file. Buttons.phtml : <div id="rh-buttons-temp" class="actions" data-bind="scope:'rh-buttons'"> <!--...
5
votes
4answers
7k views

Best Way Of Getting Base URL Inside KnockoutJS .html File

How can I get the base URL inside a KnockoutJS HTML file? See file below: app/design/frontend/<Vendor>/<Theme>/Magento_Checkout/web/template/<Filename>.html
0
votes
1answer
65 views

How to make div collapsible in ko template?

We often want to make store credit or adding gift card div collapsible on checkout page. How to make store credit or customer balance div collapsible in knockout template?
0
votes
1answer
184 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. ...
0
votes
1answer
292 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 ...
0
votes
1answer
16 views

Moving Coupon Block in Checkout Knockout Error

I moved the Discount block from the billing-step to the Sidebar in the Magento 2 checkout. I disabled the original discount block in the billing-step but I am still getting the following JS error: ...
0
votes
1answer
217 views

Knockout - Unexpected identifier (SyntaxError: Unable to process binding)

I am getting the following error in the browser console: knockout.js:2982 Uncaught SyntaxError: Unable to process binding "ifnot: function(){return customer().fullname }" Message: Unable to ...
0
votes
0answers
49 views

Knockout Js not found Magento 2.3

I am unable to click on menus, submenu in admin Panel. I have checked and found there are errors related to knockout.js in console panel. Front-end is working fine but i can see the same knockout ...
2
votes
0answers
41 views

knockout data-bind issue on the Frontend Magento 2

I have added file-uploader component in the review form. I have used below code to add browse button in the form. <div class="upload-wrapper" data-bind="scope: 'uploader'"> ...
3
votes
3answers
279 views

Magento 2 Knockout variable from response in controller via ajax

Assume I've got something like this <div class="greet welcome" data-bind="scope: 'customer'"> <!-- ko if: blockIsLoggedIn == '1' --> <span data-bind="...
0
votes
1answer
480 views

Get subtotals excluding tax for each Tax Rate in Cart summary - Magento 2

I need to calculate the SubTotal for each tax rate in my cart summary.. How can I do this? I found calculation start in module_tax under vendor / magento folder.. but I did not found where to put my ...
1
vote
0answers
25 views

Magento 2: Preload shipping estimation without filling up shipping address details

In checkout cart summary, is there a way to preload the shipping estimation without filling up the detail and choosing the shipping method? so when we first load it will show subtotal, shipping rate, ...
0
votes
0answers
18 views

Change cart qty from onestep checkout

I need to change cart qty via js while on the /checkout page(not in /checkout/cart). Then start the checkout process again with new data. Is this possible?
1
vote
0answers
110 views

How can i Stop calling event bind with data-mage-init

I am implementing infinite scroll in a custom collection which is working perfectly but in my case when i filter out this collection and update collection item with ajax response still the previously ...
1
vote
0answers
47 views

ko template: getTemplate() after AJAX not working(DOM append)

Page with products has loading by ajax(infinity scroll loading), response with products are Html page, from which new products search by class(Jqury) and appended to existing page, as a result is a ...
0
votes
1answer
137 views

'getFormattedPrice' undefined on checkout

I need to get a list under each product in the form: - Unit price - Amount - Amount based on price and quantity Rewrite template: vendor/magento/module-checkout/view/frontend/web/template/summary/...
1
vote
2answers
116 views

Hide company field on checkout step based on customer group in Magento 2.3?

I am working on checkout step for hiding the company field on the basis of customer group. can anyone help me to solve this ? Thanks
9
votes
3answers
10k views

magento2 check if customer is logged in or not in knockout template

How do I check if customer is logged in or not in knockout template? my template <!-- ko if: customer().firstname --> <!-- /ko --> my js define( [ 'ko', 'jquery', ...
0
votes
1answer
137 views

knockout template html file in adminhtml area is not rendering

I am trying to initialize the knockout component in the admin html area, the respective code is below. phtml file to initialize ko template <?php /** * @var \JC\ChatSupport\Block\Adminhtml\...
2
votes
1answer
311 views

How to translate text in shipping-estimation.html

I need to translate the text Enter your billing address to get a tax estimate. in vendor\magento\module-checkout\view\frontend\web\template\cart\shipping-estimation.html It is a text showing in the ...
1
vote
1answer
3k views

Add custom javascript in afterRender in Magento 2 with knockout

I`m trying to load a custom script after a custom-template for minicart items is rendered. I created a javascript file vendor\module\view\frontend\web\js\test.js: define('jquery', function($) { ...
1
vote
2answers
2k views

Knockout js : Read parent of parent's data

I want to read the parent of parent elements data. But, I can't able to read it properly. My Array Screenshot : My Code : <!-- ko foreach: { data: Object.keys($parent.optionParam()[main_id]), as:...
0
votes
0answers
1k views

Magento 2 : ko observable variable checking in template file

I have created a custom payment method using knockout js. I want to display a form only for selecting a drop-down value "Add new card". I have created a KO variable and assign the value initially as ...
2
votes
1answer
1k views

Magento 2 - Add new attribute (delivery_time) to recently viewed widget

What files need to be changed to display additional attributes in recently view products widget? In the widget settings there is only name, price, image and learn_more available. For the product ...
1
vote
0answers
477 views

How to pass value from template.html to js in magento 2 knockout js when complete entering the input field?

1) I need to pass the phone number value to the telephone.js when complete entering the number before the button click. 2)Below the phone number field, I added the OTP input field (i added it in the ...
1
vote
0answers
55 views

How to add selected items on a page to a separate block in Magento 2?

Please help with the implementation of this functionality. I have a separate module with a separate route. There will be elements on the page (picture and checkbox under it) as in the screenshot. ...
2
votes
1answer
368 views

How to call knockout functions from html (Magento 2)

I have functions defined in my knockout js, define([ 'Magento_Ui/js/form/form', 'ko' ], function (Component, ko) { 'use strict'; function viewedProducts() { let rvp = JSON....
0
votes
1answer
51 views

Magento2 : Show Three Products on Checkout page in Order Summary section

I have added 8 products in the cart and now I would like to show three products on Order Summary section on Checkout page with a Load More button. And, if we click on Load More button, it will show ...
1
vote
0answers
39 views

Show all error messages in one place in one page checkout

I want to show validation messages in one place. for example. <div class="checkout-error-message"> * Please fill address field * Please fill email field * Please check agreement and term </...
8
votes
1answer
3k views

Magento 2 custom module override knockout template

How can we override a knockout template in a custom module? I know how we can do this in our own theme but I need this in a module. For example I like to override this file: vendor/magento/module-...