How to add custom fields in the Confirmation page of checkout on elbrus version

When we need to have a custom field in the confirmation page we can use to override confirmationCreateResult the function in LiveOrder.Model.js.The code has been added below

     , confirmationCreateResult: function confirmationCreateResult(placed_order) {

                var self = this
                    , result = {
                        internalid: placed_order.getId()
                        , tranid: placed_order.getFieldValue('tranid')
                        , custbody_jj_tempcard_stripe: placed_order.getFieldValue('custbody_jj_tempcard_stripe')
                        , custbody_stripepaymentlink: placed_order.getFieldValue('custbody_stripepaymentlink')
                        , entity: placed_order.getFieldValue('entity')
                        , currency: placed_order.getFieldValue('currencysymbol')
                        , summary: {
                            subtotal: Utils.toCurrency(placed_order.getFieldValue('subtotal'))
                            , subtotal_formatted: Utils.formatCurrency(placed_order.getFieldValue('subtotal'))

                            , taxtotal: Utils.toCurrency(placed_order.getFieldValue('taxtotal'))
                            , taxtotal_formatted: Utils.formatCurrency(placed_order.getFieldValue('taxtotal'))

                            , shippingcost: Utils.toCurrency(placed_order.getFieldValue('shippingcost'))
                            , shippingcost_formatted: Utils.formatCurrency(placed_order.getFieldValue('shippingcost'))

                            , handlingcost: Utils.toCurrency(placed_order.getFieldValue('althandlingcost'))
                            , handlingcost_formatted: Utils.formatCurrency(placed_order.getFieldValue('althandlingcost'))

                            , discounttotal: Utils.toCurrency(placed_order.getFieldValue('discounttotal'))
                            , discounttotal_formatted: Utils.formatCurrency(placed_order.getFieldValue('discounttotal'))

                            , giftcertapplied: Utils.toCurrency(placed_order.getFieldValue('giftcertapplied'))
                            , giftcertapplied_formatted: Utils.formatCurrency(placed_order.getFieldValue('giftcertapplied'))

                            , total: Utils.toCurrency(placed_order.getFieldValue('total'))
                            , total_formatted: Utils.formatCurrency(placed_order.getFieldValue('total'))
                        }
                    }
                    , i = 0;

                result.promocodes = [];

                var promocode = placed_order.getFieldValue('promocode');

                //If legacy behavior is present & a promocode is applied this IF will be true
                //In case stackable promotions are enable this.record.getFieldValue('promocode') returns null
                if (promocode) {
                    result.promocodes.push({
                        internalid: promocode
                        , code: placed_order.getFieldText('couponcode')
                        , isvalid: true
                        , discountrate_formatted: ''
                    });
                }

                for (i = 1; i <= placed_order.getLineItemCount('promotions'); i++) {
                    result.promocodes.push({
                        internalid: placed_order.getLineItemValue('promotions', 'couponcode', i)
                        , code: placed_order.getLineItemValue('promotions', 'couponcode_display', i)
                        , isvalid: placed_order.getLineItemValue('promotions', 'promotionisvalid', i) === 'T'
                        //TODO Uncomment this line when this issue is fixed: https://system.netsuite.com/app/crm/support/issuedb/issue.nl?id=46640914&whence=&cmid=1467749011534
                        , discountrate_formatted: '' //placed_order.getLineItemValue('promotions', 'discountrate', i)
                    });
                }

                result.paymentmethods = [];

                for (i = 1; i <= placed_order.getLineItemCount('giftcertredemption'); i++) {
                    result.paymentmethods.push({
                        type: 'giftcertificate'
                        , giftcertificate: {
                            code: placed_order.getLineItemValue('giftcertredemption', 'authcode_display', i)
                            , amountapplied: placed_order.getLineItemValue('giftcertredemption', 'authcodeapplied', i)
                            , amountapplied_formatted: Utils.formatCurrency(placed_order.getLineItemValue('giftcertredemption', 'authcodeapplied', i))
                            , amountremaining: placed_order.getLineItemValue('giftcertredemption', 'authcodeamtremaining', i)
                            , amountremaining_formatted: Utils.formatCurrency(placed_order.getLineItemValue('giftcertredemption', 'authcodeamtremaining', i))
                            , originalamount: placed_order.getLineItemValue('giftcertredemption', 'giftcertavailable', i)
                            , originalamount_formatted: Utils.formatCurrency(placed_order.getLineItemValue('giftcertredemption', 'giftcertavailable', i))
                        }
                    });
                }

                result.lines = [];
                for (i = 1; i <= placed_order.getLineItemCount('item'); i++) {

                    var line_item = {
                        item: {
                            id: placed_order.getLineItemValue('item', 'item', i)
                            , type: placed_order.getLineItemValue('item', 'itemtype', i)
                        }
                        , quantity: parseInt(placed_order.getLineItemValue('item', 'quantity', i), 10)
                        , rate: parseInt(placed_order.getLineItemValue('item', 'rate', i), 10)
                        , options: self.parseLineOptionsFromSuiteScript(placed_order.getLineItemValue('item', 'options', i))
                    };

                    if (self.isPickupInStoreEnabled) {
                        if (placed_order.getLineItemValue('item', 'itemfulfillmentchoice', i) === '1') {
                            line_item.fulfillmentChoice = 'ship';
                        }
                        else if (placed_order.getLineItemValue('item', 'itemfulfillmentchoice', i) === '2') {
                            line_item.fulfillmentChoice = 'pickup';
                        }
                    }

                    result.lines.push(line_item);
                }

                StoreItem.preloadItems(_(result.lines).pluck('item'));

                _.each(result.lines, function (line) {
                    line.item = StoreItem.get(line.item.id, line.item.type);
                });

                return result;
            }

We can possibly to extend the view OrderWizardModuleConfirmation of the confirmation page.We can show the field value in confirmation page.

define('JJ_Confirm_Page'
	, [
		'Utils'
		, 'underscore'
		, 'OrderWizard.Module.Confirmation'
	]
	, function StripeCustom(
		Utils
		, _
		, OrderWizardModuleConfirmation
	) {
		'use strict';

		_.extend(OrderWizardModuleConfirmation.prototype, {
			getContext: _.wrap(OrderWizardModuleConfirmation.prototype.getContext, function (fn) {
				var context = fn.apply(this, _.toArray(arguments).slice(1));
				console.log(context, 'context')
				console.log(this.model.get("confirmation"), 'this.model.get("confirmation")')
				console.log(this.model, 'this.model")')
				var confrimation = this.model.get("confirmation")
				var customfeilds = confrimation && confrimation.attributes.customlist ? confrimation.attributes.customlist : {}
				console.log(confrimation.attributes.customlist, 'stripepayment')
				if (customfeilds && (customfeilds.custbody_payment_confirmed_checkbox === 'F')) {
					var stripepayment = confrimation && confrimation.attributes.customlist.custbody_stripe_external_link ? JSON.parse(confrimation.attributes.customlist.custbody_stripe_external_link) : {}
					console.log(stripepayment, 'stripepayment')
					context.stripepayment = stripepayment
					context.stripepaymentfail = true;
				}
				else {
					context.stripepaymentfail = false;
				}
				return context;
			})
		})



	});

Leave a comment

Your email address will not be published. Required fields are marked *