How to add column in sales_order table using db_schema.xml Magento 2?

You can add a new column in sales_order table using db_schema.xml under your module etc folder from Magento 2.3 and Upper version.

We try to add a new column called order_country in sales_order table.

To add order_country field in sales_order table, you need to only add one row inside the db_schema.xml file structure.

Here, the Main table for Sales Operation is sales_order and you can add a new field in sales_order table by the below way, Continue reading “How to add column in sales_order table using db_schema.xml Magento 2?”

Payment list template Override using mixins.js in Magento 2.

What is Javascript Mixins in Magento 2?

    • Mixin is an alternative to inheritance, without overriding the entire base file, You can add new methods or change/modify the current method output in the mixins file.
    • Mixins is a class that contains methods for use by other classes without having to be the parent class of those other classes.
    • Class Methods are added to or mixed in with parent class methods.

Continue reading “Payment list template Override using mixins.js in Magento 2.”

Get subtotal, shipping total and Grand total in checkout page using js Magento 2.

You can get total related information in the checkout page with a subtotal, shipping charge, grand total using Javascript.

For getting update grand total with the shipping charge and tax total and other info you need to call ‘Magento_Checkout/js/model/totals’ in the JS file.

You need to call totals Objects with a required field,

define([
    'uiComponent',
    'Magento_Checkout/js/model/totals'
], function (Component,totals) {
    'use strict';

    return Component.extend({
        getGrandTotal: function(){
            if (totals.totals()) {
                var grandTotal = parseFloat(totals.totals()['grand_total']);
                return grandTotal;
            }
        },
        getSubTotal: function(){
            if (totals.totals()) {
                var subtotal = parseFloat(totals.totals()['subtotal']);
                return subtotal;
            }
        },
        getShippingAmount: function(){
            if (totals.totals()) {
                var shippingAmount = parseFloat(totals.totals()['shipping_amount']);
                return shippingAmount;
            }
        }
    });
});

You can call above function in template with getGrandTotal(), getShippingAmount() and getSubTotal().